akhauriyash/Code-Regression huggingface dataset:
#include <iostream>   
#include<stack> 
#include<queue> 
#include<string> 
#include <math.h>
using namespace std;

const int MAX_H = 1000;
const int MAX_W = 1000;
const int a = 100000000;

typedef pair<int, int> P;

int H = 0, W = 0, N = 0; 
 
int food[11][2];
char cheese[MAX_H][MAX_W] = {0}; 
int r[MAX_H][MAX_W]; 
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; 

int search(int &sx, int &sy, int &ex, int &ey)
{
 
    P p;
    queue<P> que;
    for(int i=0; i<H; i++)
   {
        for(int j=0; j<W; j++)
       {
           r[i][j] = a;

        }
    }
    que.push(P(sx,sy));
    r[sx][sy] = 0;

    while(que.size())
   {  
        p = que.front();
        que.pop();
        if(p.first == ex && p.second == ey)
			break;
	

	    for(int i=0; i<4; i++)
	   {
		    int xn = p.first + dx[i];
		    int yn = p.second + dy[i];


		    if(xn >= 0 && xn < H && yn >= 0 && yn < W && cheese[xn][yn]!='X' && r[xn][yn] == a )
		   {
			    que.push(P(xn,yn));
			    r[xn][yn] = r[p.first][p.second] + 1;
		    }
	    }

	}
	return r[ex][ey];
}

int main()
{
	int dis = 0;
    cin >> H >> W >> N;
    for(int i=0; i<H; i++)
   {
        for(int j=0; j<W; j++)
       {
          cin >> cheese[i][j];
          if(cheese[i][j] == 'S')
         {
             food[0][0] = i;
             food[0][1] = j;
             cheese[i][j] = '.';
          }
          if(cheese[i][j]>48&&cheese[i][j]<58)
         {
             int num = cheese[i][j] - 48;  
             food[num][0] = i;
             food[num][1] = j;
          }
       }
    }
   

    for(int i=0; i<N; i++)
   {
       dis += search(food[i][0], food[i][1], food[i+1][0], food[i+1][1]); 
    }
    
	cout << dis << endl;
    return 0;
}

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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, l; cin >> n >> l;
	int a = l, b = l + n - 1;
	int c = 0;
	if(a > 0) c = a;
	else if(b < 0) c = b;
	cout << (2 * l + n - 1)*n/2 - c;
} 

Measured memory_bytes: 256
def main():
    from itertools import product

    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]

    ans = 3000
    for prod in product([0, 1, 2, 3], repeat=N):
        t = [[] for _ in range(3)]
        for i, x in enumerate(prod):
            if x == 3: continue
            t[x].append(i)
        if (not t[0]) or (not t[1]) or (not t[2]): continue

        cost = sum(len(t[i]) - 1 for i in range(3)) * 10
        a = sum(L[i] for i in t[0])
        b = sum(L[i] for i in t[1])
        c = sum(L[i] for i in t[2])
        cost += abs(A - a) + abs(B - b) + abs(C - c)
        if ans > cost:
            ans = cost

    print(ans)


if __name__ == '__main__':
    main()


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

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int lneed,rneed;
    lneed=rneed=0;
    rep(i,n){
        if(s[i]=='('){
            int tmp=1;
            bool flag=1;
            rep(j,i+1,n){
                if(s[j]==')'){
                    --tmp;
                }
                else ++tmp;
                if(tmp==0){
                    flag=0;
                    break;
                }
            }
            if(flag){
                ++rneed;
            }
        }
        else{
            int tmp=1;
            bool flag=1;
            for(int j=i-1;j>=0;--j){
                if(s[j]=='('){
                    --tmp;
                }
                else ++tmp;
                if(tmp==0){
                    flag=0;
                    break;
                }
            }
            if(flag){
                ++lneed;
            }
        }
    }
    rep(i,lneed) cout<<'(';
    cout<<s;
    rep(i,rneed) cout<<')';
    cout<<endl;
}
    

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

int main()
{
	long long w, h, x, y;
	cin >> w >> h >> x >> y;

	int ret = 0;
//	if (x == w / 2 && y == h / 2) {
	if(x*2 == w && y*2 == h){
		ret = 1;
	}

	//cout << (double)w * (double)h * 0.5 << " " << ret << endl;
	printf("%.9f %d", (double)w * (double)h / 2, ret);

	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++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int a,b;
    cin >> a >> b;
    rep(i,to_string(b).length()){
        a*=10;
    }
    int res = a+b;
    for(int i = 0;i<=res;i++){
        if(i*i==res){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int a,b,c;
    cin >> a >> b>> c;
    print(max(a,max(b,c))-min(a,min(b,c)));
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int M = scan.nextInt();

		double totalVote = 0;

		// 商品の投票数
		List<Integer> voteList = new ArrayList();

		// 投票数リスト作成
		for(int i = 0; i < N; i++) {
			voteList.add(scan.nextInt());
		}
		// 降順ソート
		Collections.sort(voteList, Collections.reverseOrder());

//		for(int i = 0; i < voteList.size(); i++) {
//			// System.out.println(voteList.get(i));
//			totalVote += (int)voteList.get(i);
//		}
		for(int i :voteList) {
			totalVote += i;
		}

		// 総評数
		//System.out.println(totalVote);

		if((int)voteList.get(M-1) >= totalVote/(4 * M)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 27220
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false), cin.tie(NULL);
typedef vector < int > VI;
const ll mod= 1e9+7,INF=1e18,mx= 5e6+5,mn=100;
int testCase=1,cas=0;

vector <ll> Divisor;

void Make(ll n) {

    ll val=sqrt(n);

    for(ll i=1; i<=val; i++) {
        if(n%i==0) {
            Divisor.push_back(i);
            Divisor.push_back(n/i);
        }
    }

}

ll Find(ll x) {
    ll cnt=0;
    while(x>0) {
        cnt++;
        x/=10;
    }
    return cnt;
}

int main() {
    Fast_Input

    //cin>>testCase;
    while(testCase--) {
        ll n;
        cin>>n;
        Make(n);
        ll cnt=INF;
        sort(all(Divisor));
        ll lim=Divisor.size();

        for(ll i=0; i<lim; i++) {
            for(ll j=i+1; j<lim; j++) {
                if(Divisor[i]*Divisor[j]==n) {
                    ll x= Find(Divisor[i]);
                    ll y= Find(Divisor[j]);
                    cnt=min(cnt,max(x,y));
                    //cout<<x<<" "<<Divisor[i]<<" "<<Divisor[j]<<endl;
                }
            }

        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())

dp = [0]*(10**5+1)
for i in range(1, 10**5+1):
	dp[i] = dp[i-1]+1
	cnt = 0
	while 6**cnt<=i:
		dp[i] = min(dp[i], dp[i-6**cnt]+1)
		cnt += 1
	cnt = 0
	while 9**cnt<=i:
		dp[i] = min(dp[i], dp[i-9**cnt]+1)
		cnt += 1
print(dp[N])

Measured memory_bytes: 69020
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
l,r=0,10**9
f=0
while r-l>1:
    m=(l+r)//2
    count=0
    for i in a:
        count+=math.ceil(i/m)-1
    if count<=k:
        r=m
    else:
        l=m
print(r)

Measured memory_bytes: 31160
#include <stdio.h>
int abs(int n){
		if(n<0){
		return -1*n;}else
		return n;}
int main(void)
{int N,A,M,B,C,x,i,a,b,c,l,r,g,m,tmp;
	scanf("%d",&N);
if(N%3==0)
	printf("%d",N/3);
	else
	printf("%d",N/3);


	return 0;
}


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

int main ()
{
	string s;
	cin>>s;
	
	if(s=="SAT")
	{
		cout<<"1"<<endl;
	}
	if(s=="SUN")
	{
		cout<<"7"<<endl;
	}
	if(s=="MON")
	{
		printf("6\n");
	}
	if(s=="TUE")
	{
		printf("5\n");
	}
	if(s=="WED")
	{
		printf("4\n");
	}
	if(s=="THU")
	{
		printf("3\n");
	}
	if(s=="FRI")
	{
		printf("2\n");
	}
	
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = gets.chomp.split.map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split.map(&:to_i)

def linear_search(numbers, length, sentinel)
  i = 0
  numbers << sentinel
  while numbers[i] != sentinel
    i += 1
  end
  return i != length
end

sum = 0
t.each do |num|
  sum += 1 if linear_search(s, s.length, num)
end

puts sum

Measured memory_bytes: 9064
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

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


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <list>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  int a,b;
  cin >> a >> b;
  int ans = (a-1)*(b-1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int b=0,c=0;
    for(int i = 0; i<a.size();i++){
        if(a[i]== '+') b++;
        if(a[i]== '-') c++;
    }
    int k = b-c;
    cout<<k;
    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int hp = sc.nextInt();
		int n = sc.nextInt();
		int td = 0;

		for(int i = 0; i < n; i++) {
			td += sc.nextInt();
		}

		System.out.println(hp <= td ? "Yes" : "No");
	}
}

Measured memory_bytes: 58672
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[3][105];
int pre[3][105];
int32_t main(){
	int n;cin>>n;
	for(int i=1;i<=2;i++){
		for(int j=1;j<=n;j++){
			cin>>ar[i][j];
			pre[i][j]=pre[i][j-1]+ar[i][j];
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		ans = max(ans,pre[1][i]+pre[2][n]-pre[2][i-1]);
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N, M, Q;
  while (cin >> N >> M >> Q) {
    vec<int, 2> sum = make_v(N + 1, N + 1, 0);
    for (int i = 0; i < M; i++) {
      int L, R;
      cin >> L >> R;
      ++sum[L][R];
    }
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
      }
    }
    for (int t = 0; t < Q; t++) {
      int p, q;
      cin >> p >> q;
      int res = sum[q][q] - sum[p - 1][q];
      cout << res << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    ll ans = 0; int i = 1, j = n - 1;
    while (j >= i) {
        if (i < n) {
            ans += a[i - 1];
        }
        if (j > i) {
            ans += a[i];
        }
        i++;
        j--;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll l = 0, r = 10e9;
    while (l+1 < r) {
      ll mid = (l+r)/2;
      ll cnt = 0;
      rep(i,n) {
        cnt += (a[i]-1)/mid;
      }
      if (cnt <= k) r = mid;
      else l = mid;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 4836
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;

    int d = a / b;
    int r = a % b;
    double f = 1.0 * a / b;
    std::cout << d << " " << r << " "
              << std::fixed << f << std::endl;

    return 0;
}

Measured memory_bytes: 1240
function main()
  n, m = map(s -> parse(Int, s), split(readline()))
  mod = 10^9 + 7
  ans = 1
  i = 2

  while i * i <= m
    if m % i == 0
      count = 0
      while m % i == 0
        count += 1
        m /= i
      end
      ans *= comb(n + count - 1, count, mod)
      ans %= mod
    end
    i += 1
  end

  if m > 1
    ans *= n
    ans %= mod
  end

  println(ans)
end

function comb(n, k, m)
  if (n - k < k) return comb(n, n - k, m) end
  nume = 1
  deno = 1
  for i = 0:k - 1
    nume *= n - i
    deno *= i + 1
    nume %= m
    deno %= m
  end
  return (nume * modpow(deno, m - 2, m)) % m
end

function modpow(a, p, m)
  if p == 0
    return 1
  elseif p % 2 == 0
    return modpow(a, p / 2, m)^2 % m
  else
    return a * modpow(a, p - 1, m) % m
  end
end

main()


Measured memory_bytes: 113192
#include <bits/stdc++.h>
#define up(i,a,b) for(int i=a;i<=b;i++)
#define down(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a-1;i>=b;i--)
#define CL(x) (x<<1)
#define CR(x) (x<<1)+1
#define pb push_back
#define bit1(x) __builtin_popcount(x)
#define self (*this)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,pii> plii;
#define x first
#define y second

template<typename T> inline void _read(T &x){
    char ch; x=0; bool neg=false;
    for(ch=getchar();ch<'0'||ch>'9';ch=getchar())
        if(ch=='-') neg=true;
    for(;ch>='0'&&ch<='9';ch=getchar()) x=10*x+ch-'0';
    if(neg) x=-x;
}
#define read(a) _read(a)
#define Read(a,b) _read(a),_read(b)
#define READ(a,b,c) _read(a),_read(b),_read(c)

const int maxn=1e2+7;
const int Nblocks=400;
const int maxS=(1<<5)+7;
const ll mod=9901;
const int inf=1e9+7;
const ll linf=1e16+9;
const double pi=4*atan(1);
const ll Radix=1e9;
const int Length=9;
const int MaxDigit=2e4+1;
const int nDigits=MaxDigit/Length+1;

int n,a,x;
int res;

inline void Enter(){
    cin>>n>>x;
}

inline void Solve(){
    #define Kamisama
    up(i,1,n) cin>>a,res=__gcd(res,abs(a-x));
    cout<<res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    #ifndef Kamisama
    freopen("TEST.INP","r",stdin);
    freopen("TEST.OUT","w",stdout);
    #endif // Kamisama

    Enter();
    Solve();

    return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	int ans = (n - 1)*(m - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <stack>
#include <math.h>
#include <stdio.h>
#define ll long long
#define anf 0x3f3f3f3f
using namespace std;

int main()
{
    ll n;
    stack<int>v;
    cin>>n;

    if(n==0)
        cout<<'0';

    while(n)
    {
        int a=abs(n%(-2));
        v.push(a);
        n=(n-a)/(-2);
    }

    while(!v.empty())
    {
        cout<<v.top();
        v.pop();
    }

    cout<<endl;
    return 0;
}


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

using namespace std;

long long cost[6] = {};
long long out = LONG_MAX;
long long find(long long n, map<long long, long long> &memo)
{
  long long w = 9e18;
  if(n < 9e18 / cost[1])
    w = n * cost[1];

  if(n == 0)
    return 0;

  if(n == 1)
    return cost[1];

  if(memo[n])
    return memo[n];

  for(long long i = 1; i < 6; i++)
  {
    if(i == 2 || i == 3 || i == 5)
    {
      if(n % i == 0)
      {
        w = min(w, cost[i] + find(n / i, memo));
      }
      else
      {
        int rem = n % i;
        long long tmp = rem * cost[1];
        long long tn = n - rem;
        w = min(w, tmp + cost[i] + find(tn / i, memo));

        rem = i - rem;
        tmp = rem * cost[1];
        tn = n + rem;
        w = min(w, tmp + cost[i] + find(tn / i, memo));
      }
    }
  }

  memo[n] = w;
  return w;
}

int main()
{
  int t;
  cin >> t;
  while(t--)
  {
    long long n, A, B, C, D;
    cin >> n >> A >> B >> C >> D;
    cost[2] = A;
    cost[3] = B;
    cost[5] = C;
    cost[1] = D;

    map<long long, long long> mxx;
    cout << find(n, mxx) << endl;
  }
}


Measured memory_bytes: 4236
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    double A, B;
    cin >> A >> B;
    B--;
    A = ceil(B / (A - 1));
    cout << A << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int vis[100010];
vector<int> g[100010],a;

int get(int pos){
	int v=a[pos]; vis[pos]=1;
	for(auto x:g[pos]) if(!vis[x]) v+=get(x);
	return v%26;
}

int main(){FIN;
	string s; int q; cin>>s>>q;
	s="a"+s+"a";
	fore(i,1,SZ(s)) a.pb((s[i]-s[i-1]+26)%26);
	int n=SZ(a);
	fore(i,0,n) g[i].pb(n-i-1);
	while(q--){
		int l,r;cin>>l>>r;
		g[l-1].pb(r); g[r].pb(l-1);
	}
	fore(i,0,n) if(!vis[i]&&get(i)) cout << "NO\n",exit(0);
	cout<<"YES\n";
}//pingo

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, L;
  cin >> N >> L;

  int sum = 0, mi = 1e9;
  for ( int i = 0; i < N; i++ ) {
    sum += L+i;
    if ( abs(L+i) < abs(mi) ) {
      mi = L+i;
    }
  }

  cout << sum-mi << endl;
  
  return 0;
}


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

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

int main() {

	int a, b;
	cin >> a >> b;

	if ((a + b) % 2 == 0)
		cout << (a + b) / 2 << endl;
	else
		cout << "IMPOSSIBLE" << endl;

	return 0;
}

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

using namespace std;

vector<string> split_string(string);

int main()
{
   string s1, s2;
   cin >> s1 >> s2;

   for(int i = 0; i < s1.size(); i++){
       if(s1[i] != s2[i]){
           cout << "No";
           return 0;
       }
   }
   cout << "Yes";

}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
 
using namespace std;
 
using ll = long long;
 
#define all(x) begin(x), end(x)
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); 

bool ispal(string s){
	string t = s;
	reverse(all(t));
	return t == s;
}
 
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
string s; cin >> s;
int n = s.size();
if(ispal(s) && ispal(s.substr(0,(n-1)/2)) && ispal(s.substr((n+1)/2)))
	cout << "Yes" << "\n";
else cout << "No" << "\n";


 
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


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



int main() {

	ll K, S;
	cin >> K >> S;

	ll ans = 0;

	rep(i, K + 1)rep(j, K + 1) {
		ll z = S - i - j;
		if (z >= 0 && z <= K) { ans++; }
	}

	cout << ans;
	

	system("PAUSE");
}


Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a - 1)*(b - 1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		if(N/100 == N%10)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;

void m_sort(int a[], int tmp[], int left, int right);
void m_sort(int a[], int tmp[], int left, int right);
void sort(int a[], int total) {
	int tmp;
	for (int i = 0; i < total; i++) {
		for (int j = i + 1; j < total; j++) {
			if (a[i] < a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}

}

void mergeSort(int a[], int tmp[], int size)
{
	m_sort(a, tmp, 0, size - 1);
}
void merge(int a[], int tmp[], int left, int mid, int right)
{
	int i, left_end, num_elements, tmp_pos;

	left_end = mid - 1;
	tmp_pos = left;
	num_elements = right - left + 1; // 要素 

	while ((left <= left_end) && (mid <= right))
	{
		if (a[left] <= a[mid])
		{
			tmp[tmp_pos] = a[left];
			tmp_pos = tmp_pos + 1;
			left = left + 1;
		}
		else
		{
			tmp[tmp_pos] = a[mid];
			tmp_pos = tmp_pos + 1;
			mid = mid + 1;
		}
	}


	while (left <= left_end)
	{
		tmp[tmp_pos] = a[left];
		left = left + 1;
		tmp_pos = tmp_pos + 1;
	}

	while (mid <= right)
	{
		tmp[tmp_pos] = a[mid];
		mid = mid + 1;
		tmp_pos = tmp_pos + 1;
	}


	for (i = 0; i <= num_elements; i++)
	{
		a[right] = tmp[right];
		right = right - 1;
	}
}
void m_sort(int a[], int tmp[], int left, int right)
{
	int mid;

	if (right > left)
	{
		mid = (right + left) / 2;
		m_sort(a, tmp, left, mid);
		m_sort(a, tmp, mid + 1, right);

		merge(a, tmp, left, mid + 1, right);
	}
}


long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

bool c;
int point,N;
int H, T, R, G, M, K, W, t[101], v[101], ans, now;
char S,s,X,Y;

int main() {
	cin >> X >> Y;
	char i = 'A';
	if (X == Y) {
		cout << "=" << endl;
		return 0;
	}
	while(1){
		if (X == i){
			cout << "<" << endl;
			return 0;
		}
		if (Y == i) {
			cout << ">" << endl;
			return 0;
		}
		i++;
	}

	return 0;
}




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

int main() {
  int N, D;
  cin >> N >> D;
  
  int X[N][D];
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }
  
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      int dist = 0;
      for (int k = 0; k < D; k++) {
        dist += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      
      if (int(sqrt(dist)) * int(sqrt(dist)) == dist) count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<fstream>
#include<sstream>
#include<queue>
#include<iterator>
#include<stack>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(b<=c)cout<<0<<endl;
	else if(c<=a&&d>=b)cout<<b-a<<endl;
	else if(c>=a&&d>=b)cout<<b-c<<endl;
	else if(c>=a&&d<=b)cout<<d-c<<endl;
	else if(c<=a&&d>=a)cout<<d-a<<endl;
	else cout<<0<<endl;






  return 0;
}


Measured memory_bytes: 256
n,s = map(int,input().split())
a = list(map(int,input().split()))
dp = [[0 for i in range(s+1)] for j in range(n+1)]
dp[0][0] = 1
MOD = 998244353
for i in range(n):
    for j in range(s+1):
        dp[i+1][j] = dp[i][j]*2
        if a[i] <= j:
            dp[i+1][j] += dp[i][j-a[i]]
        dp[i+1][j] %= MOD
print(dp[n][s])

Measured memory_bytes: 147132
#include <cstdio>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;
#define inf (1<<27)
#define abs(n) ((n)>=0?(n):-(n))
#define next(p) ((p)%5+1)
typedef pair<int,int> P;
typedef pair<int,P> P2;
int d[6][1000];
int o[6];
int dist(P &a,P &b) {return abs(a.first-b.first)+abs(a.second-b.second);}
int main() {
	int x,y;
	while(scanf("%d%d",&x,&y),x) {
		vector<P> p[7];
		for(int j=0;j<y;j++) {
			getchar();
			for(int i=0;i<x;i++) {
				char ch=getchar();
				if(ch=='S')p[0].push_back(P(i,j));
				else if(ch=='G')p[6].push_back(P(i,j));
				else if(ch!='.')p[ch-'0'].push_back(P(i,j));
			}
		}
		o[0]=0;o[5]=6;
		int min_m,min_d=inf;
		for(int m=1;m<=5;m++) {
			for(int t=next(m),i=1;i<=4;i++,t=next(t))o[i]=t;
			fill(d[0],d[0]+6*1000,inf);
			d[0][0]=0;
			priority_queue<P,vector<P2>,greater<P2> > que;
			que.push(P2(0,P(0,0)));
			while(!que.empty()) {
				P2 p2=que.top();que.pop();
				if((p2.second.first+1)>=6)continue;
				if(d[p2.second.first][p2.second.second]<p2.first)continue;
				for(int i=0;i<p[o[p2.second.first+1]].size();i++) {
					if(d[p2.second.first+1][i]>p2.first+dist(p[o[p2.second.first]][p2.second.second],p[o[p2.second.first+1]][i])) {
						d[p2.second.first+1][i]=p2.first+dist(p[o[p2.second.first]][p2.second.second],p[o[p2.second.first+1]][i]);
						que.push(P2(d[p2.second.first+1][i],P(p2.second.first+1,i)));
					}
				}
			}
			if(min_d>d[5][0]) min_m=m,min_d=d[5][0];
		}
		if(min_d==inf)printf("NA\n");
		else printf("%d %d\n",min_m,min_d);
	}
}

Measured memory_bytes: 1332
// ~maqsat~
/*    
**    “Anyone who has never made a mistake has never tried anything new.”
**    © Albert Einstein
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
    fre("");
    ACCELERATE;
	
	int a, b, c;
	cin >> a >> b >> c;

	ll ans = min(a, c);
	c = max(0, c - a);

	if(c) {
		int x = min(b, c);
		ans += x * 2;
		b -= x;
		c -= x;
	}
	else {
		ans += b;
		b = 0;
	}

	if(b) {
		ans += b;
		b = 0;
	}
	else if(c) {
		ans++;
	}

	cout << ans;
    return 0;
}
/*
 
*/

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int A, B, K;
  cin >> A >> B >> K;

  int N = 0;
  for (int i = min(A, B); i >= 1; i--) {
    if (A % i == 0 && B % i == 0) {
      N += 1;
      if (N == K) {
        cout << i << endl;
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);

            s = Console.ReadLine().Split(' ');

            int[] X = new int[N];

            for (int i = 0; i < N; i++)
            {
                X[i] = int.Parse(s[i]);
            }

            Array.Sort(X);

            int[][] L = new int[M][];

            for(int i=0;i<M;i++)
            {
                s = Console.ReadLine().Split(' ');
                L[i] = new int[2];

                L[i][0] = int.Parse(s[0]);
                L[i][1] = int.Parse(s[1]);
            }

            OrgComparer comp = new OrgComparer();
            Array.Sort(L, comp);

            int counter = 0;

            for(int i=0;i<M;i++)
            {
                for (int j = 0; j < L[i][0]; j++)
                {
                    if (X[counter] < L[i][1])
                    {
                        X[counter] = L[i][1];
                        counter++;
                    }
                    else
                        counter = N;

                    if (counter == N)
                        break;
                }

                if (counter == N)
                    break;
            }

            for(int i=0;i<N;i++)
            {
                ans += X[i];
            }

            Console.WriteLine(ans.ToString());
        }
    }

    public class OrgComparer : System.Collections.IComparer
    {
        //配列２項目目で昇順
        public int Compare(object x, object y)
        {
            int[] X = (int[])x;
            int[] Y = (int[])y;

            if (X[1] > Y[1])
                return -1;
            if (X[1] < Y[1])
                return 1;

            return 0;
        }
    }
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -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;}

//-----------------------------------------

//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll q;
  cin >> q;
  set<ll> st;
  REP(i,q){
    ll com;
    cin >> com;
    if(com == 0){
      ll x; cin >> x;
      st.insert(x);
      cout << st.size() <<endl;
    }
    else if(com == 1){
      ll x; cin >> x;
      cout << (st.find(x) != st.end()) <<endl;
    }
    else if(com == 2){
      ll x;
      cin >> x;
      st.erase(x);
    }
    else{
      ll l, r;
      cin >> l >> r;
      auto s = st.lower_bound(l);
      auto t = st.upper_bound(r);
      for(auto i = s; i != t; ++i){
        cout << (*i) << endl;
      }
    }
  }
  return 0;
}




Measured memory_bytes: 12512
n = int(input())
A = list(map(int, input().split()))

def trace():
    for i in range(len(A)):
        if i != len(A) - 1:
            print(A[i],end=' ')
        else:
            print(A[i])
        


for i in range(len(A)):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v

    trace()


Measured memory_bytes: 5984
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Data.List
import Data.Maybe

main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  hs <- fmap VU.fromList $ fmap sort $ (replicateM n $ do
    (i,_) <- fromJust  . B.readInt <$> B.getLine 
    return i)
  xs <- VU.forM (VU.fromList [k-1..n-1]) $ \i -> return $ (hs VU.! i) - (hs VU.! (i-k+1))
  print $ VU.minimum xs 


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

bool judge(int num) {
  vector<int> n(5);
  for(int i = 0; i < 5; i++) {
    n.at(i) = num % 10;
    num /= 10;
  }
  if(n.at(0) == n.at(4) && n.at(1) == n.at(3)){
    return true;
  }
  else {
    return false;
  }
}


int main() {
  int A, B;
  cin >> A >> B;

  int count = 0;
  for(int i = A; i <= B; i++) {
    if(judge(i)) {
      count++;
    }
  }
  cout << count << endl; 
}

Measured memory_bytes: 256
N = int(input())
V = list(map(int,input().split()))

from collections import Counter

def get_counter(X):
  counter = Counter(X)
  X = counter.most_common()
  X.append((0,0))
  return X

V1 = get_counter(V[::2])
V2 = get_counter(V[1::2])

if V1[0][0] != V2[0][0]:
  print(N - (V1[0][1] + V2[0][1]))
else:
  print(N - max(V1[0][1] + V2[1][1],V1[1][1] + V2[0][1]))


Measured memory_bytes: 25264
#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
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<string> S;
  S.emplace_back("AC");
  S.emplace_back("WA");
  S.emplace_back("TLE");
  S.emplace_back("RE");
  vector<int> cnt(S.size(),0);
  for(int i=0; i<N; i++){
    string s;
    cin >> s;
    for(int j=0; j<S.size(); j++){
      if(S[j] == s){
        cnt[j]++;
      }
    }
  }
  for(int i=0; i<S.size(); i++){
    cout << S[i] << " x " << cnt[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 3652
n = int(input())
A = [*map(int, input().split())] + [0]
dp_yen = [0]*(n+1)
dp_yen[0] = 1000
for day in range(n):
    dp_yen[day+1] = max(dp_yen[day], dp_yen[day] + (A[day+1] - A[day]) * (dp_yen[day] // A[day]))
print(dp_yen[n])


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

int main(){
	int n;
	cin >> n;
	int *a = new int[n];
	for(int i=0; i<n;i++){
			cin >> a[i];
	}
	reverse(a, a + n);

	for(int j=0 ;j<n-1;j++){
		cout << a[j] << " ";
	}
	cout << a[n-1]<< "\n";
	delete[] a;
}

Measured memory_bytes: 1200
a_reizo, b_renge, m_quopon = gets.chomp.split(' ').map(&:to_i)
reizoko_ary = gets.chomp.split(' ').map(&:to_i)
renge_ary = gets.chomp.split(' ').map(&:to_i)

min_price = reizoko_ary.min + renge_ary.min
m_quopon.times do
  quopon = gets.chomp.split(' ').map(&:to_i)
  price = reizoko_ary[quopon[0]-1] + renge_ary[quopon[1]-1] - quopon[2]
  min_price = price if min_price > price
end

puts min_price

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}

int main(){
  char ans;
  cin>>ans;
  if(isupper(ans)){
    cout<<"A"<<endl;
  }else{
    cout<<"a"<<endl;
  }

  return 0;
  
  
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    ll k;
    cin >> n >> k;
    vector<ll> Negative, Positive;
    int ZeroCnt = 0;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        if(a == 0)  ++ZeroCnt;
        else if(a < 0)  Negative.emplace_back(-a);
        else    Positive.emplace_back(a);
    }
    sort(Negative.begin(), Negative.end());
    sort(Positive.begin(), Positive.end());

    int PositiveCnt = Positive.size();
    int NegativeCnt = Negative.size();
    ll bound = (ll)PositiveCnt * NegativeCnt;
    ll zero = (ll)ZeroCnt * (ZeroCnt - 1) / 2;
    zero += (ll)ZeroCnt * (PositiveCnt + NegativeCnt);
    if(bound < k && k <= bound + zero){
        cout << 0 << endl;
        return 0;
    }
    
    ll ans;
    if(k <= bound){
        auto check = [&](ll x) -> bool {
            ll res = 0;
            for(ll val : Positive){
                ll val2 = x / val;
                if(x % val != 0)    ++val2;
                res += Negative.end() - lower_bound(Negative.begin(), Negative.end(), val2);
            }
            return res >= k;
        };
        ll lb = 1, ub = 1e+18 + 1;
        while(ub - lb > 1){
            ll mid = (lb + ub) >> 1;
            if(check(mid))  lb = mid;
            else    ub = mid;
        }
        ans = -lb;
    }
    else{
        k -= bound + zero;
        auto check = [&](ll x) -> bool {
            ll res = 0;
            for(int i = 0; i < PositiveCnt - 1; ++i){
                ll val = Positive[i];
                res += upper_bound(Positive.begin() + i + 1, Positive.end(), x / val) - (Positive.begin() + i + 1);
            }
            for(int i = 0; i < NegativeCnt - 1; ++i){
                ll val = Negative[i];
                res += upper_bound(Negative.begin() + i + 1, Negative.end(), x / val) - (Negative.begin() + i + 1);
            }
            return res >= k;
        };
        ll lb = 0, ub = 1e+18;
        while(ub - lb > 1){
            ll mid = (lb + ub) >> 1;
            if(check(mid))  ub = mid;
            else    lb = mid;
        }
        ans = ub;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<tuple>
#include<map>
#include<set>
#include<algorithm>
 
#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};
 
signed main(){
	int N;
	vector<int> l;
	cin >> N;
	rep(2*N){
		int tmp;
		cin >> tmp;
		l.push_back(tmp);
	}
	sort(all(l), greater<int>());
	int ans = 0;
	rep(N){
		ans += l[2*i+1];
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
typedef long long i64;
const int N=200007,P=1e9+7,inf=0x3f3f3f3f;
int n,ys[N];
struct pos{
	int x,y;
	bool operator<(pos w)const{return x<w.x;}
}ps[N];
int _l,_r,_a;
struct node{
	node*lc,*rc;
	int L,R,M;
	int sum,mul;
	void _mul(int x){
		sum=i64(sum)*x%P;
		mul=i64(mul)*x%P;
	}
	void dn(){
		if(mul!=1){
			lc->_mul(mul);
			rc->_mul(mul);
			mul=1;
		}
	}
	void up(){
		sum=(lc->sum+rc->sum)%P;
	}
	void sums(){
		if(_l<=L&&R<=_r){
			_a=(_a+sum)%P;
			return;
		}
		dn();
		if(_l<=M)lc->sums();
		if(_r>M)rc->sums();
	}
	void muls(){
		if(_l<=L&&R<=_r){
			_mul(2);
			return;
		}
		dn();
		if(_l<=M)lc->muls();
		if(_r>M)rc->muls();
		up();
	}
	void adds(){
		if(L==R){
			sum=(sum+_a)%P;
			return;
		}
		dn();
		(_l<=M?lc:rc)->adds();
		up();
	}
}ns[N*2],*rt,*np=ns;
node*build(int L,int R){
	node*w=np++;
	w->L=L;w->R=R;
	w->mul=1;
	w->sum=0;
	if(L<R){
		int M=w->M=(L+R)>>1;
		w->lc=build(L,M);
		w->rc=build(M+1,R);
	}
	return w;
}
int ls[N],rs[N];
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d%d",&ps[i].x,&ps[i].y);
		ys[i]=ps[i].y;
	}
	std::sort(ys+1,ys+n+1);
	for(int i=1;i<=n;++i)ps[i].y=std::lower_bound(ys+1,ys+n+1,ps[i].y)-ys;
	std::sort(ps+1,ps+n+1);
	ls[n+1]=inf;rs[0]=-inf;
	for(int i=1;i<=n;++i)rs[i]=max(rs[i-1],ps[i].y);
	for(int i=n;i>=1;--i)ls[i]=min(ls[i+1],ps[i].y);
	rt=build(1,n);
	for(int i=1,pw2=1;i<=n;++i,pw2=pw2*2%P){
		int l1=ls[i],r1=rs[i];
		if(l1==1){
			_l=r1;_a=pw2;
			rt->adds();
		}else{
			_l=1,_r=l1-2;
			if(_l<=_r)rt->muls();
			_l=l1-1,_r=r1,_a=0;
			if(_l<=_r)rt->sums();
			_l=r1;
			rt->adds();
		}
	}
	_l=_r=n,_a=0;
	rt->sums();
	printf("%d\n",(_a%P+P)%P);
	return 0;
}

Measured memory_bytes: 19712
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=11;
int n,a[N];
void main() {
    R(n);
    REP(i,n) R(a[i]);
    LL ans=1;
    REP(i,n) ans*=3;
    LL cnt=1;
    REP(i,n) if ( a[i]%2==0 ) cnt*=2;
    ans-=cnt;
    W(ans);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 256