akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
ld eps=1e-9;

int H, W;
int dx[4] = { -1,-1,0,0 };
int dy[4] = { -1,0,0,-1 };
bool check(const vector<vector<int>>&v,const int x, const int y) {
	if (!x || !y || x == W || y == H)return true;
	set<int>s;
	for (int i = 0; i < 4; ++i) {
		if (v[y + dy[i]][x + dx[i]]) {
			s.emplace(v[y + dy[i]][x + dx[i]]);
		}
	}
	return s.size() != 4;
}
int getans(vector<vector<int>>&v,const int num) {
	for (int y = 0; y < H; ++y) {
		for (int x = 0; x < W; ++x) {
			if (!v[y][x]) {
				int ans = 0;
				v[y][x] = num;
				if(x!=W-1&&!v[y][x+1]){
					v[y][x + 1] = num;
					if (check(v, x, y) && check(v, x + 2, y) && check(v, x + 2, y + 1) && check(v, x, y + 1)) {
						ans += getans(v, num + 1);
					}
					v[y][x + 1] = 0;
				}
				if(y!=H-1){
					v[y+1][x] = num;
					if (check(v, x, y) && check(v, x + 1, y) && check(v, x + 1, y + 2) && check(v, x, y +2)) {
						ans += getans(v, num + 1);
					}
					v[y+1][x] = 0;
				}
				v[y][x] = 0;
				return ans;
			}
		}
	}
	return 1;
}
int main() {
	while (1) { cin >> H >> W;
		if (!H)break;
		vector < vector<int>>v(H, vector<int>(W));
		int ans = getans(v, 1);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3032
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	string res = "";
	if (N == 0) res = "0";
	while (N != 0) {
		if (N % 2 == 0) {
			res = "0" + res;
		}
		else {
			N--;
			res = "1" + res;
		}
		N /= -2;
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    nums=list(map(int,input().split(" ")))
    votes=list(map(int,input().split(" ")))
    total=0
    n=0
    for i in votes:
        total+=i
    for i in votes:
        if(i>=total/(4*nums[1])):
            n+=1
    if n>=nums[1]:
        print("Yes")
    else:print("No")

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;

int main(){
    int hosei[]={0,4,0,1,4,6,2,4,0,3,5,1,3};
    string day[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
    int m,n;
    while(1){
        cin>>m>>n;
        if(!(m||n))break;
        cout<<day[(hosei[m]+n%7-1)%7]<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 1196
s_list = list(map(int,(input())))
count_odd1 = 0
count_odd0 = 0
count_even1 = 0
count_even0 = 0
s_len = len(s_list)
for i in range(s_len):
    if i%2 == 0 and s_list[i] == 1:
        count_odd1 += 1
    if i%2 == 1 and s_list[i] == 1:
        count_even1 += 1

    if i%2 == 0 and s_list[i] == 0:
        count_odd0 += 1
    if i%2 == 1 and s_list[i] == 0:
        count_even0 += 1
# print(count_even0)
# print(count_odd1)
# print(count_even1)
# print(count_odd0)
print(min(s_len - count_even0 - count_odd1,s_len - count_even1 - count_odd0))

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

int main(){

  int vertex_num, time;
  cin >> vertex_num;
  vector<vector<int>> adjacent_graph;
  adjacent_graph.resize(101);
  int discover[101],finished[101];
  rep(i,101) discover[i] = finished[i] = -1;

  rep(i,vertex_num){
    int vertex, adjacent_num,tmp;
    vector<int> input_graph;
    cin >> vertex >> adjacent_num;
    rep(j,adjacent_num){
      cin >> tmp;
      input_graph.emplace_back(tmp);
    }
    adjacent_graph[vertex] = input_graph;
  }

  stack<int> stk;
  time = 0;
  for(int i=1;i<=vertex_num;i++){
    if(discover[i] == -1){
      stk.emplace(i);
      discover[i] = ++time;
    }
    while(!stk.empty()){
      int now = stk.top();
        bool hasnext = false;
        rep(j,adjacent_graph[now].size()){
          int next = adjacent_graph[now][j];
          if(discover[next] == -1) {
            discover[next] = ++time;
            stk.emplace(next);
            hasnext = true;
            break;
          }
        }
        if(!hasnext){   
        finished[now] = ++time;
        stk.pop();
        }
    }
  }

  for(int i =1;i<=vertex_num; i++){
    cout << i << " " << discover[i] << " " << finished[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3172
n = input()
a = list(map(int,input().split()))

a.sort()

hist = [0 for x in range(-1,max(a)+3)]
As = []
ans = -1
Aspd = As.append

if len(a) ==1:
    print(1)
else:
    for i in a:
        hist[i] += 1
    
    for i in range(len(hist)-1):
        Aspd(hist[i-1]+hist[i]+hist[i+1])
        

    print(max(As))

Measured memory_bytes: 13964
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#define MOD 1000000007
#define endl "\n" 
#define int long long // remove when constraints are tight.
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/


int n,m,v,p;
const int N=1e5+10;
vector<int> ar;
bool can(int x)
{
	vector<int> tmp;
	if(ar[x]+m<ar[p-1])
	{
		return false;
	}
	int sum=0;
	for(int i=0;i<n;i++)
	{
		if(i>=p-1 && i<x){
			tmp.push_back(ar[x]+m-ar[i]);
		}
		else
		{
			tmp.push_back(m);
		}		
		sum+=tmp.back();
	}
	return (sum>=m*v);
}
int32_t main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m>>v>>p;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		ar.push_back(x);
	}
	sort(ar.begin(),ar.end());
	reverse(ar.begin(),ar.end());
	int start=0;
	int end=n-1;	
	while(start<=end)
	{
		if(start==end|| start==end-1)
		{
			if(can(end))
			{
				cout<<end+1<<endl;
			}
			else
			{
				cout<<start+1<<endl;
			}
			return 0;
		}
		int mid=(start+end)>>1;
		if(can(mid))
		{
			start=mid;
		}
		else
		{
			end=mid;
		}		
	}
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
typedef struct aaaaa{
  int x,y,t;
}Grid;
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  vector<int>vi(n);
  for(int i=0;i<n;i++)cin>>vi[i];
  sort(ALL(vi));
  int ans=INF*2;
  for(int i=0;i<n-k+1;i++)
    ans=min(ans,vi[i+k-1]-vi[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define ll long long int
#define int ll
#define ft    front()
#define ps(a) push(a)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define inf_1 0x7FFFFFFF
#define inf_2 0x7FFFFFFFFFFFFFFFL
#define out(a) (cout << a << endl)
#define hello(a) (cout << "hello" << a << endl)
#define out_v(v) {for(int ___i = 0; ___i < v.size(); ++___i) cout << v[___i] << " "; cout << endl;}
#define fastio {ios::sync_with_stdio(0); cin.tie(0);}
#define mm(a, b) memset(a, 0, sizeof(c));
signed main(){
    fastio;
    int n, k;
    cin >> n >> k;
    vector<int> v;
    v.pb(-1);
    for(int i = 0; i < n; ++i){
        int num;
        cin >> num;
        v.pb(num);
    }
    vector<int> se;
    int cur = 1;
    se.pb(cur);
    map<int, int> mp;
    mp[cur] = 1;
    int cyc;
    while(1){
        cur = v[cur];
        if(mp.count(cur)){
            cyc = cur;
            break;
        }
        mp[cur] = 1;
        se.pb(cur);
    }
    // out_v(se);
    for(int i = 0; i < se.size(); ++i){
        if(se[i] == cyc){
            cyc = i;
            break;
        }
    }
    if(k <= cyc){
        out(se[k]);
    }
    else{
        k -= cyc;
        int remain = k % (se.size() - cyc);
        out(se[cyc + remain]);
    }
    return 0;
}

Measured memory_bytes: 18732
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

int main() {
    int n, k; cin >> n >> k;
    vector<ll> a(n), s(n + 1, 0);

    auto mod = [](ll x, ll m) {
        ll ret = x % m;
        return (ret < 0) ? ret + m : ret;
    };

    REP(i, n) {
        cin >> a[i];
        s[i + 1] = a[i] + s[i];
    }

    map<ll, ll> mp;
    REP(i, min(n + 1, k)) {
        mp[mod(s[i] - i, k)]++;
    }

    ll ans = 0;
    REP(i, n + 1) {
        mp[mod(s[i] - i, k)]--;

        ans += mp[mod(s[i] - i, k)]; 

        if (i + k <= n) {
            mp[mod(s[i + k] - (i + k), k)]++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15872
// BBQ Hard
// * frank_c1
// * 2017 / 09 / 29
 
#include <bits/stdc++.h>
using namespace std;

const int base = 2000;
const int mo = (int)(1e9) + 7;
int c[base * 2 + 10][base * 2 + 10];
int a[base * 2 + 10][base * 2 + 10];
int b[base * 2 + 10][base * 2 + 10];

inline void add(int& x, int v) {
	x += v; if (x >= mo) x -= mo;
}

int main() {
	int n, x, y, res = 0;
	scanf("%d", &n);
	c[0][0] = 1;
	for (int i = 0; i <= base * 2; ++i)
		for (int j = 0; j <= base * 2; ++j) {
			if (i) add(c[i][j], c[i - 1][j]);
			if (j) add(c[i][j], c[i][j - 1]);
		}
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &x, &y);
		a[base - x][base - y]++;
		b[base + x][base + y]++;
		add(res, mo - c[2 * x][2 * y]);
	}
	for (int i = 0; i <= 2 * base; ++i) {
		for (int j = 0; j <= 2 * base; ++j) {
			if (i) add(a[i][j], a[i - 1][j]);
			if (j) add(a[i][j], a[i][j - 1]);
			while (b[i][j]--) add(res, a[i][j]);
		}
	} 
	return printf("%lld\n", (1LL * res * (mo + 1) / 2) % mo), 0;
}

Measured memory_bytes: 188672
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

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

  int a, b, c, d;
  int flag = 0;
  REP(i, 0, 6){
    if (i==0){
      a=0;b=1;c=2;d=3;
    }
    if (i==1){
      a=0;b=2;c=1;d=3;
    }
    if (i==2){
      a=0;b=3;c=1;d=2;
    }
    if (i==3){
      a=1;b=2;c=0;d=3;
    }
    if (i==4){
      a=1;b=3;c=0;d=2;
    }
    if (i==5){
      a=2;b=3;c=0;d=1;
    }
  if ( (S[a] == S[b]) and (S[c] == S[d]) and (S[b] != S[c]) )
    flag = 1;
  }

  if (flag == 1)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

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

int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll a,b,c,d;
    
    cin>>a>>b>>c>>d;
    
    ll count = 0;
    
    ll num = b-a - (b/c)-(b/d)+((a-1)/c)+((a-1)/d)+(b/(lcm(c,d)))-((a-1)/lcm(c,d));
    
    cout<<num+1<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int count = 0;
    int sum;

    for (int i=1; i <= N; i++) {
      String stringN = String.valueOf(i);
      String[] nArray = stringN.split("");

      sum = 0;
      for (int j=0; j < nArray.length; j++) {
        sum += Integer.parseInt(nArray[j]);
      }

      if (sum >= A && sum <= B) {
        count += i;
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 33876
#include<cstdio>
using namespace std;

int n,r;
int main()
{
	scanf("%d %d",&n,&r);
  
	if (n<=10)
	{
		printf("%d\n",r+100*(10-n));
	}
	else
	{
		printf("%d\n",r);
	}
  
	return 0;
}

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

int main() {
	string s;
	while (getline(cin, s), s != ".") {
		stack<char>st;
		bool flag = true;
		for (char c : s) {
			if (c == '[' || c == '(')
				st.push(c);
			if (c == ']') {
				if (st.size() && st.top() == '[')
					st.pop();
				else {
					puts("no");
					flag = false;
					break;
				}
			}
			if (c == ')') {
				if (st.size() && st.top() == '(')
					st.pop();
				else {
					puts("no");
					flag = false;
					break;
				}
			}
		}
		if (flag) {
			if (st.size())puts("no");
			else puts("yes");
		}
	}
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

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

    int d = 0;
    int cnt = 1;
    rep(i,n)
    {
        d += l[i];
        if(d>x) break;
        cnt++;
    }

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

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <climits>
using namespace std;

class node{
    int c;
    int h;
    node* p;
public:
    node(){c=0;h=0;p=NULL;}
    void incC(){c++;}
    void setHP(int height, node* parent){
        h = height;
        p = parent;
    }
    int getC(){return c;}
    pair<int,node*> getHP(){
        if(this->p==NULL)return make_pair(0, this);
        else{
            pair<int,node*> tmp = p->getHP();
            tmp.first += h;
            return tmp;
        }
    }
};

node ob[100000];

int diff(int x, int y){
    pair<int,node*> tmp1 = ob[x].getHP();
    pair<int,node*> tmp2 = ob[y].getHP();
    if(tmp1.second != tmp2.second)return INT_MAX;
    else return tmp2.first - tmp1.first;
}

void relate(int x, int y, int z){
    pair<int,node*> tmp1 = ob[x].getHP();
    pair<int,node*> tmp2 = ob[y].getHP();
    if(tmp1.second == tmp2.second)return;
    if(tmp1.second->getC() < tmp2.second->getC()){
        tmp1.second->setHP(tmp2.first - tmp1.first - z, tmp2.second);
    }else{
        tmp2.second->setHP(tmp1.first - tmp2.first + z, tmp1.second);
        if(tmp1.second->getC() == tmp2.second->getC()){
            tmp1.second->incC();
        }
    }
}

int main(){
    int i,n,q,com,x,y,z,tmp;
    scanf("%d %d",&n,&q);
    for(i=0;i<q;i++){
        scanf("%d",&com);
        if(com){
            scanf("%d %d",&x,&y);
            int tmp = diff(x,y);
            if(tmp==INT_MAX)printf("?\n");
            else printf("%d\n",diff(x,y));
        }else{
            scanf("%d %d %d",&x,&y,&z);
            relate(x,y,z);
        }
    }
    return 0;
}



Measured memory_bytes: 4300
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n,k;
    cin>>n>>k;
    vector<int> A(n),f(n);
    for(auto &a : A) cin>>a;
    for(auto &a : f) cin>>a;
    sort(A.begin(),A.end());
    sort(f.begin(),f.end());
    reverse(f.begin(),f.end());
    
    auto check = [&](ll m){
        ll sum = 0ll;
        for(int i=n-1;i>=0;--i){
            sum += max(0ll,A[i] - m/f[i]);
        }
        return (sum <= k)?true:false;
    };
    ll l = 0; ll r = 1e12;
    while(r-l>0){
        ll mid = (r+l)/2;
        if(check(mid)) r = mid;
        else l = mid+1;
    }
    cout << l << endl;
    
    return 0;
}



Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int go(ll n) {
	int cnt = 0;
	while (n > 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}

int main(){
	ll n;
	cin >> n;
	int ans = 1000;
	for (ll i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ans = min(ans, max(go(n / i), go(i)));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;

int
main(int argc, char *argv[])
{
  int q[100000];
  char s[100000];
  fgets(s, 99999, stdin);

  int n = strlen(s);

  int qi = 0; int i = 0;
  while(i < n){
    if(s[i] == '+'){
      q[qi - 2] = q[qi - 2] + q[qi - 1];
      qi--; i += 2;
    }
    else if(s[i] == '-'){
      q[qi - 2] = q[qi - 2] - q[qi - 1];
      qi--; i += 2;
    }
    else if(s[i] == '*'){
      q[qi - 2] = q[qi - 2] * q[qi - 1];
      qi--; i += 2;
    }
    else{
      int k = 0; int d = 1000000;
      while(s[i] != ' '){
	k += (int)(s[i] - '0') * d;
	d /= 10;
	i++;
      }
      q[qi] = k / (d * 10);
      qi++;
      i++;
    }
  }

  printf("%d\n", q[qi - 1]);

  return 0;
}
       



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

ll a[2000], dp[2000][2000];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%lld", &a[i]);
	ll Max = 0;
	for (int t = 1; t <= n; t++) {
		rep(i, n) {
			int j = (i + t - 1) % n;
			if (t == 1) {
				if (!((n - t) & 1))dp[i][j] = a[i];
				continue;
			}
			if ((n - t) & 1) {
				if (a[i] > a[j])dp[i][j] = dp[(i + 1) % n][j];
				else dp[i][j] = dp[i][(j + n - 1) % n];
			}
			else dp[i][j] = max(dp[(i + 1) % n][j] + a[i], dp[i][(j + n - 1) % n] + a[j]);
			Max = max(Max, dp[i][j]);
		}
	}
	printf("%lld\n", Max);
}

Measured memory_bytes: 34468
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String b = sc.next();

        if (b.equals("A")) {
            System.out.println("T");
        } else if (b.equals("T")) {
            System.out.println("A");
        } else if (b.equals("G")) {
            System.out.println("C");
        } else {
            System.out.println("G");
        }
    }

}


Measured memory_bytes: 22228
// +build ignore
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func solve(sc *scanner, wr *bufio.Writer) int {
	N := sc.i()

	// nmax := 10000
	for i := 1; i <= N; i++ {
      ans := 0
      for x := 1; x*x <= i; x++ {
          for y := 1; (x*x + y*y + x*y) <= i; y++ {
              for z := 1; x*x+y*y+z*z+x*y+y*z+x*z <= i; z++ {
                  v := x*x + y*y + z*z + x*y + y*z + x*z
                  if v == i {
                    ans++
                  }
              }
          }
      }
      fmt.Println(ans)
    }

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


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

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

  string result;

  int length = S.size();
  int count = 0;
  while(count < length){
    result.push_back(S[count]);
    count += w;
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <string>
#include <unordered_map>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)

using namespace std;

int main(void){
	int N,i,ans;
	string S[200000];
	unordered_map<string, int> mp;
	cin >> N;
	myfor(i,N){
		cin >> S[i];
		mp[S[i]] = 1;
	}
	ans = mp.size();
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 23924
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   int l, r;
   int ans = 0;
   for(int i=0; i<N; ++i){
      std::cin >> l >> r;
      ans += r - l + 1;
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 10000
#define NIL -1

struct Node{
  int parent, left, right;
};

struct Node Tree[MAX];
int Depth[MAX], Height[MAX];

void setDepth(int, int);
int setHeight(int);
int Sibling(int);
void Print(int);

int main(){
  int n,i,num,l,r;
  int root = 0;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++) Tree[i].parent = NIL;

  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d",&num,&l,&r);
    Tree[num].left = l;
    Tree[num].right = r;
    if(l != NIL) Tree[l].parent = num;
    if(r != NIL) Tree[r].parent = num;
  }

  for(i = 0 ; i < n ; i++) if(Tree[i].parent == NIL) root = i;

  setDepth(root,0);
  setHeight(root);

  for(i = 0 ; i < n ; i++) Print(i);

  return 0;
}

void setDepth(int x, int y){
  if(x == NIL) return;
  Depth[x] = y;
  setDepth(Tree[x].left, y+1);
  setDepth(Tree[x].right, y+1);
}

int setHeight(int x){
  int h1 = 0, h2 = 0;
  if(Tree[x].left != NIL) h1 = setHeight(Tree[x].left) + 1;
  if(Tree[x].right != NIL) h2 = setHeight(Tree[x].right) + 1;

  if(h1 > h2) return Height[x] = h1;
  else return Height[x] = h2;
}

int Sibling(int x){
  if(Tree[x].parent == NIL) return NIL;
  if(Tree[Tree[x].parent].left != x && Tree[Tree[x].parent].left != NIL){
    return Tree[Tree[x].parent].left;
  }
  if(Tree[Tree[x].parent].right != x && Tree[Tree[x].parent].right != NIL){
    return Tree[Tree[x].parent].right;
  }

  return NIL;
}

void Print(int x){
  int degree = 0;
  printf("node %d: ",x);
  printf("parent = %d, ",Tree[x].parent);
  printf("sibling = %d, ",Sibling(x));
  if(Tree[x].left != NIL) degree++;
  if(Tree[x].right != NIL) degree++;
  printf("degree = %d, ",degree);
  printf("depth = %d, ",Depth[x]);
  printf("height = %d, ",Height[x]);

  if(Tree[x].parent == NIL){
    printf("root\n");
  }
  else if(Tree[x].left == NIL && Tree[x].right == NIL){
    printf("leaf\n");
  }
  else printf("internal node\n");
}


Measured memory_bytes: 2132
/*************************************************************************
> File Name: test.cpp
> Author: Akira
> Mail: qaq.febr2.qaq@gmail.com
************************************************************************/
 
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;
 
#define MaxN 100001
#define MaxM MaxN*4
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9 + 7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x;
int N, M;
struct Edge
{
	int u, v, next;
}edge[MaxM];
int cont;
int head[MaxN];
vector<int> V[MaxN];
void add(int u, int v)
{
	edge[cont].u = u;
	edge[cont].v = v;
	edge[cont].next = head[u];
	head[u] = cont++;
}
void Add(int u, int v) { add(u, v); add(v, u); }
int low[MaxN];
int dfn[MaxN];
int Stack[MaxN], top;
int belong[MaxN];
int vis[MaxN];
int Index, cnt;
void Tarjan(int u)
{
	low[u] = dfn[u] = Index;
	Index++;
	Stack[++top] = u;
	vis[u] = 1;
	for (int i = head[u]; i != -1; i = edge[i].next)
	{
		int v = edge[i].v;
		if (dfn[v] == -1)
		{
			Tarjan(v);
			low[u] = min(low[u], low[v]);
		}
		else if (vis[v])
		{
			low[u] = min(low[u], dfn[v]);
		}
	}
	if (low[u] == dfn[u])
	{
		for (int v=-1; v != u; top--)
		{
			v = Stack[top];
			vis[v] = false;
			belong[v] = cnt;
			V[cnt].push_back(v);
		}
		cnt++;
	}
}
int col[MaxN];
bool BFS(int x)
{
	col[x] = 1;
	queue<int> Q;
	Q.push(x);
	while (!Q.empty())
	{
		int u = Q.front();
		Q.pop();
		for (int i = head[u]; i != -1; i = edge[i].next)
		{
			int v = edge[i].v;
			if (col[v] == col[u]) return false;
			else
			{
				if (col[v] == -1)
				{
					col[v] = col[u] ^ 1;
					Q.push(v);
				}
			}
		}
	}
	return true;
}
bool judge(int x)
{
	MST(col, -1);
	for (int i = 0; i<V[x].size(); i++)
	{
		int node = V[x][i];
		if (col[node] == -1 && !BFS(node)) return false;
	}
	return true;
}
void init()
{
	cont = 0;
	MST(head, -1);
	MST(dfn, -1);
	CLR(low);
	CLR(vis);
	Index = cnt = 1;
	top = 0;
	for (int i = 1; i <= N; i++) V[i].clear();
}
int main()
{
	//std::ios::sync_with_stdio(false);
	while (~scanf("%d%d", &N, &M))
	{
		init();
		while (M--)
		{
			int u, v;
			scanf("%d%d", &u, &v);
			Add(u, v);
		}
		for (int i = 1; i <= N; i++)
			if (dfn[i] == -1) Tarjan(i);
		//cout << cnt << endl;
		LL I = 0, Q = 0, P = 0;
		for (int i = 1; i<cnt; i++)
		{
			if (V[i].size() == 1) I++;
			else
			{
				if (judge(i)) Q++;
				else P++;
			}
		}
		//cout << I << " " << Q << " " << P << endl;
		LL ans = 2 * I*N - I*I + P*P + 2 * P*Q + 2 * Q*Q;
		printf("%lld\n", ans);
	}
	//system("pause");
}

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

int main(void)
{
    string S;
    int strLen = 0;
    int maxLen = 0;
    cin >> S;

    for (int i = 0; i < S.size(); i++)
    {
        if ((S[i] == 'A') || (S[i] == 'C') || (S[i] == 'G') || (S[i] == 'T'))
        {
            strLen++;
            if (strLen > maxLen)
                maxLen = strLen;
        }
        else
        {
            strLen = 0;
        }
    }
    cout << maxLen << endl;

    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	string s;
	cin >> s;
	int ans = 0;
	for (int i=0;i<s.size();i++)
	{
		if (s[i] == '+')
		{
			ans++;
		}
		else
		{
			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! {
        n: usize,
        h: [isize; n],
    }

    let mut dp = vec![std::isize::MAX; n];
    dp[0] = 0;

    for (i, _) in h.iter().enumerate() {
        if i != (h.len() - 2) {
            let cost = (h[i] - h[i + 1]).abs() + dp[i];
            if dp[i + 1] > cost {
                dp[i + 1] = cost;
            }

            let cost = (h[i] - h[i + 2]).abs() + dp[i];
            if dp[i + 2] > cost {
                dp[i + 2] = cost;
            }
        } else {
            let cost = (h[i] - h[i + 1]).abs() + dp[i];
            if dp[i + 1] > cost {
                dp[i + 1] = cost;
            }
            break;
        }
    }

    println!("{:?}", dp.last().unwrap());
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	cin >> n;
  	int ma = 0 , ans = 0;
 	for(int i = 0 ; i < n ; i++)
    {
		int x;
      	cin >> x;
      	if(x >= ma){ 
          ans++;
          ma = x;
        }
      	
    }
  	cout << ans << endl;

 	return 0; 
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N;
ll int tmp;
vector<ll int> a;

int main(){
    scanf("%d", &N);
    REP(i, N){
        scanf("%lld", &tmp);
        a.push_back(tmp - i);
    }

    sort(a.begin(), a.end());

    int m = N / 2;
    ll int ans = 0;

    REP(i, N){
        ans += abs(a[i] - a[m]);
    }

    printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 2420
#include<stdio.h>

int main(void){
   int A,B,C,D;
   int a,b,s;
   scanf("%d%d%d%d",&A,&B,&C,&D);
   if(A<=B)    a=A;
   else           a=B;
   if(C<=D)    b=C;
   else           b=D;
   s=a+b;
   printf("%d\n",s);
   return 0;
}

Measured memory_bytes: 128
A, B = gets.split.map(&:to_i)
ds = []
(1..A).each do |i|
    ds[i] = [nil] + gets.split.map(&:to_i)
end

fs = Array.new(101){Array.new(101, 0)}
(0..100).each do |a|
    (0..100).each do |b|
        (1..A).each do |x|
            (1..B).each do |y|
                val = ds[x][y] - x*a - y*b
                fs[a][b] = val if fs[a][b] < val
            end
        end
    end
end

(1..A).each do |x|
    (1..B).each do |y|
        result = 10**10
        (0..100).each do |a|
            (0..100).each do |b|
                val = x*a+y*b+fs[a][b]
                result = val if result > val
            end
        end
        if ds[x][y] != result
            puts 'Impossible'
            exit
        end
    end
end

N = 202
S, T = 1, 202
M = 200 + 101 ** 2

puts 'Possible'
puts [N, M].join(' ')
(1..100).each do |i|
    puts [i, i+1, 'X'].join(' ')
end
(102..201).each do |i|
    puts [i, i+1, 'Y'].join(' ')
end
(0..100).each do |a|
    (0..100).each do |b|
        puts [S+a, T-b, fs[a][b]].join(' ')
    end
end
puts [S, T].join(' ')

Measured memory_bytes: 2172
#include <stdio.h>

int main (){
	int a,b;
	scanf ("%d %d",&a,&b);
	int hasil1=a+b;
	int hasil2=a-b;
	int hasil3=a*b;
	if (hasil1>hasil2&&hasil1>hasil3){
		printf ("%d\n",hasil1);
	}
	else if (hasil2>hasil1&&hasil2>hasil3){
		printf ("%d\n",hasil2);
	}
	else if (hasil3>hasil1&&hasil3>hasil2){
		printf ("%d\n",hasil3);	
	}
	else printf ("%d\n",hasil1);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
using namespace std;
typedef long long int ll;

string s[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string t; cin >> t;
	for(int i=0;i<7;i++){
		if(s[i]==t){
			cout << (7-i) << endl;
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[10010],i;
  scanf("%s",s);
  for(i=1;s[i];i++){
    if(s[i-1]=='A'&&s[i]=='C')break;
  }
  printf("%s\n",s[i]?"Yes":"No");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str;
    cin >> str;
    
    string ans;

    string zero = "0";
    string one = "1";
    string b = "B";

    for(int i=0;i<str.length();i++){
        if(str.compare(i,1,zero)==0){
            ans += zero;
        }else if(str.compare(i,1,one)==0){
            ans += one;
        }else{
            if(ans.length()>0){
                ans.erase(ans.length()-1,1);
            }
        }
    }

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

Measured memory_bytes: 256
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    // 入力を受け取る
    let large_h: usize = iter.next().unwrap().parse().unwrap();
    let large_w: usize = iter.next().unwrap().parse().unwrap();
    let h: usize = iter.next().unwrap().parse().unwrap();
    let w: usize = iter.next().unwrap().parse().unwrap();

    // マス目の合計
    let sum_mass: usize = large_h * large_w;
    // 黒色の塗りの際に重複が発生するマス目
    let overlap_mass: usize = h * w;
    // 重複を排除した黒色の箇所 = h * large_w + w * large_h - overlap_mass
    let painted_mass: usize = h * large_w + w * large_h - overlap_mass;
    // 残り白色のマス
    let white_mass: usize = sum_mass - painted_mass;

    println!("{}", white_mass);
}

Measured memory_bytes: 4352
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int M1, M2, D1, D2;
	cin >> M1 >> D1 >> M2 >> D2;

	cout << (M1 != M2) << "\n";

	return 0;
}

Measured memory_bytes: 256
import sys
def sign(x):
    if x>0: s=1
    elif x<0: s=-1
    else: s=0
    return s

def f(p1,p2,p3):
    x1,y1 = p1
    s = sign((p3[1]-y1)*(p2[0]-x1)-(p2[1]-y1)*(p3[0]-x1))
    return s

for s in sys.stdin:
    D = map(float, s.split(","))
    p1 = D[0:2]
    p2 = D[2:4]
    p3 = D[4:6]
    p4 = D[6:8]
    x = f(p1,p3,p2) != f(p1,p3,p4) and f(p2,p4,p1) != f(p2,p4,p3)
    print ["NO","YES"][x]

Measured memory_bytes: 4256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {												
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/wjex/cp/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  

vi conv(vi &a ,vi &b ){
	vi ret(sz(a));
	rep(i,0,sz(a)) ret[i] = a[b[i]];
	return ret;
}


void solve(){
	int n , k;  
	re(n,k);
	vi a (n+1); fr(i,1,n)  cin >> a[i];
	auto get= [&](vi v , int b){
		vi ret(sz(v)) ;
		iota(all(ret),0);
		while(b){
			if(b&1){
					ret = conv(ret,v);
			}
			v=conv(v,v);
			b>>=1;
		}
		return ret;
	}; 
	cout << get(a,k)[1] << endl;
}
	

signed main() {
	unsyncIO();
	int tt =1 ;
	//cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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


int main(){int x1, x2, y1, y2; 
cin >> x1 >> y1 >> x2 >> y2;
// int ans;
int x3, x4, y3, y4;
// x3 = x2 + y2 - y1;
// y3 = y2 + x1 - x2;
// x4 = x1 + y2 - y1;
// y4 = y1 + x1 - x2;
x4 = x1 + y1 - y2;
y4 = y1 + x2 - x1;
x3 = x2 + y1 - y2;
y3 = y2 + x2 - x1;

cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll MAX = 1e2+2;
const ll MAX1=1e5+2;
const ll INF=1e15;
const ll MOD=1e9+7;



int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    vector<ll>dp(k+1);
    dp[0]=1;
    ll a[n];
    for(int i=0;i<n;i++)
    {    
        cin>>a[i];
        vector<int>fake(k+1);
        
        for(int j=k;j>=0;j--)
        {
            ll tmp=dp[j];
            ll l=j+1;
            ll r=j+min(a[i],k-j);
            if(l<=r)
            {
                fake[l]+=tmp;
                fake[l]%=MOD;
                if(r+1<=k)
                {    
                    fake[r+1]-=tmp;
                    fake[r+1]=(fake[r+1]+MOD)%MOD;
                }    
            }
        }
        ll psum=0;
        for(int i=0;i<=k;i++)
        {
            psum+=fake[i];
            psum%=MOD;
            dp[i]+=psum;
            dp[i]%=MOD;
        }
    }    
    cout<<dp[k]<<endl;   
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long A, long long B, long long C) {
  cout << min(C, B / A) << endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  solve(A, B, C);
  return 0;
}


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

int main(void)
{
    char s[110],t[110],tmp_s,tmp_t;
    int len_s,len_t;
    scanf("%s%s",s,t);
    len_s=(int)strlen(s);
    len_t=(int)strlen(t);
    for(int i=0;i<len_s-1;i++){
        for(int j=i+1;j<len_s;j++){
            if(s[i]>s[j]){
                tmp_s=s[j];
                s[j]=s[i];
                s[i]=tmp_s;
            }
        }
    }
    for(int i=0;i<len_t-1;i++){
        for(int j=i+1;j<len_t;j++){
            if(t[i]<t[j]){
                tmp_t=t[j];
                t[j]=t[i];
                t[i]=tmp_t;
            }
        }
    }
    printf(strcmp(s,t)<0?"Yes\n":"No\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

unsigned long gcd(unsigned long a, unsigned long b){
    if(a == b){
        return a;
    }else if(a < b){
        gcd(a, b - a);
    }else{
        gcd(b, a - b);
    }
}

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

unsigned long calcu(unsigned long Target, unsigned long C, unsigned long D){
    unsigned long C_ans, D_ans, CD_ans;
    C_ans = Target / C;
    D_ans = Target / D;
    CD_ans = Target / lcm(C, D);
    return (Target - C_ans - D_ans + CD_ans);
}

int main(){
    unsigned long A, B, C, D, pre, post;
    cin >> A >> B >> C >> D;
    pre = calcu(A - 1, C, D);
    post = calcu(B, C, D);
    cout << post - pre << endl;
}


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

int main() {
  ll n, m;
  cin >> n >> m;
  if(n==1 && m==1) cout << 1 << endl;
  else if(n==1) cout << m-2 << endl;
  else if(m==1) cout << n-2 << endl;
  else cout << (n-2)*(m-2) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String[] pa = a.split("");
		String b = sc.next();
		String[] pb = b.split("");
		if(pa.length == pb.length){
			for(int i=0;i<pa.length;i++){
				System.out.print(pa[i]+pb[i]);
			}
			System.out.println();
			return;
		}else if(pa.length > pb.length){
			for(int i=0;i<pa.length-1;i++){
				System.out.print(pa[i]+pb[i]);
			}
			System.out.println(pa[pa.length-1]);
		}
		
	}
}

Measured memory_bytes: 21844
class Node(object):

    def __init__(self, key):
        self.left = None
        self.right = None
        self.parent = None

        self.key = key


class Tree(object):

    def __init__(self):
        self.root = None

    def insert(self, new_key):
        x = self.root
        y = None

        while x is not None:
            y = x

            if new_key < y.key:
                x = y.left
            else:
                x = y.right

        new_node = Node(new_key)
        new_node.parent = y
        if y is None:
            self.root = new_node
        elif new_key < y.key:
            y.left = new_node
        else:
            y.right = new_node

    def inorder(self, now):
        visited = list()
        if now is None:
            return visited

        visited.extend(self.inorder(now.left))
        visited.append(now.key)
        visited.extend(self.inorder(now.right))
        return visited

    def preorder(self, now):
        visited = list()
        if now is None:
            return visited

        visited.append(now.key)
        visited.extend(self.preorder(now.left))
        visited.extend(self.preorder(now.right))
        return visited

    def order_print(self):
        keys = list()
        keys.append(self.inorder(self.root))
        keys.append(self.preorder(self.root))

        for visited_keys in keys:
            print "",
            print " ".join(map(str, visited_keys))

    def find(self, key):
        keys = self.inorder(self.root)
        if key in keys:
            print "yes"
        else:
            print "no"

    def min_node(self, now):
        """min_node
        Return the node with the minimum key,
        treeting now as the root of a sub tree.
        """
        if now.left is not None:
            return min_node(now.left)
        return now


    def delete(self, key):
        x = self.root
        y = None

        while x.key != key:
            y = x
            if key < y.key:
                x = y.left
            else:
                x = y.right

        # y is parent of x here
        if x.left is None and x.right is None:
            if y.left == x:
                y.left = None
            else:
                y.right = None
        elif x.left is None or x.right is None:
            child = x.left if x.left is not None else x.right
            child.parent = y
            if y.left == x:
                y.left = child
            else:
                y.right = child
        else:
            next_node = self.min_node(x.right)
            x.key = next_node.key
            self.delete(next_node)


def main():
    tree = Tree()

    num_orders = int(raw_input())
    for _ in xrange(num_orders):
        order = raw_input()
        if order[0] == 'i':
            new_key = int(order.split()[1])
            tree.insert(new_key)
        elif order[0] == 'p':
            tree.order_print()
        elif order[0] == 'f':
            key = int(order.split()[1])
            tree.find(key)
        elif order[0] == 'd':
            key = int(order.split()[1])
            tree.delete(key)


if __name__ == "__main__":
    main()

Measured memory_bytes: 230448
from collections import Counter
from collections import Counter
N, A, B = (list)(map(int, input().split()))
v = (list)(map(int, input().split()))

v = sorted(v, reverse=True)

sel_list = v[:A]
max_ave = sum(sel_list)/A
print(max_ave)

c = Counter(v)

C = [[0]*(N+1) for _ in range(N+1)]
for i in range(N+1):
    for j in range(i+1):
        if j == 0 or j == i:
            C[i][j] = 1
        else:
            C[i][j] = (C[i-1][j-1] + C[i-1][j])


def ave_n(n):
    sel_list = v[:n]
    ave = sum(sel_list)/i
    if ave != max_ave:
        return 0
    last = sel_list[-1]
    use_last = sel_list.count(last)
    return C[c[last]][use_last]


ans = 0
for i in range(A, B+1):
    ret = ave_n(i)
    if ret == 0:
        break
    else:
        ans += ret
print((int)(ans))


Measured memory_bytes: 3444