akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#define int long long
using namespace std;
int aa[123456];
signed main() {
    int n, sum = 0, a = 0, b = 0; cin >> n;
    for (int h = 0; h < 100000; h++) {
        sum += h;
        if (sum >= n) { a = h; break; }
    }
    sum = n;
    for (int h = a; h > 0; h--) {
        if (sum >= h) { sum -= h; aa[b] = h; b++; }
    }
    sort(aa, aa + b);
    for (int h = 0; h < b; h++) {
        cout << aa[h] << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
6 3
abcdef
ace
)");
#define cin input
#endif

ll gcd(int a, int b)
{
	while(a!=b)
	{
		if (a>b)
			a = a-b;
		else
			b = b-a;
	}
	return a;
}

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

int main()
{
	int n, m;
	ll l;
	cin >> n >> m;
	l = lcm(n,m);

	string s, t;
	cin >> s >> t;

	ll val = 1;
	ll ans = l;
	for(int i=0; val<=l; i++)
	{
		if (s[i*l/m] != t[i*l/n])
		{
			ans = -1;
			break;
		}
		val += (l/m)*(l/n);
	}
	cout << ans << endl;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	int n, a, b; cin >> n >> a >> b;
	if (n > 1ll * a * b || a + b - 1 > n) {
		return cout << -1 << '\n',0;
	}
	vector<int> vans;
	for (int i = b; i >= 1; --i) {
		vans.push_back(i);
	}
	int cur = b + 1;
	int lef = n - b - (a - 1);
	for (int i = 1; i < a; ++i) {
		int go = min(b - 1, lef);
		for (int j = cur + go; j >= cur; --j) {
			vans.push_back(j);
		}
		lef -= go;
		cur += go + 1;
	}
	for (int x : vans) cout << x << ' ';
}

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

int main() {
  long long num;
  long long sum = 0;
  long long Min = 0;
  long long tmp = 0;
  
  cin >> num;
  
  vector<long long> vec(num);
  for(int i = 0; i < num; i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  
  Min = sum;
  for(int i = 0; i < num; i++){
    tmp += vec.at(i);
    Min = min(Min, abs(tmp -(sum - tmp)));
  }
  
  cout << Min;
}


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

using namespace std;

bool StartsWith(string &s, string &t, int offset) {
  int slen = s.size() - offset;
  if (slen < t.size()) {
    return false;
  }

  for (int i = 0; i < t.size(); ++i) {
    if (t[i] != s[offset + i]) {
      return false;
    }
  }

  return true;
}

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;

  vector<string> vt{"dream", "dreamer", "erase", "eraser"};
  reverse(s.begin(), s.end());
  for (int i = 0; i < vt.size(); ++i) {
    reverse(vt[i].begin(), vt[i].end());
  }

  int cur = 0;
  bool ans = true;
  while (cur < s.size()) {
    int matched_idx = -1;
    for (int i = 0; i < vt.size(); ++i) {
      bool matched = StartsWith(s, vt[i], cur);
      if (matched) {
        matched_idx = i;
        break;
      }
    }

    if (matched_idx == -1) {
      ans = false;
      break;
    }

    cur += vt[matched_idx].size();
  }

  if (ans) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }

  return 0;
}

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    string t, s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < 10; i++)
        s += '0';
    for (int i = 0; i < n; i++){
        if (s.substr(i, 11) == "dreameraser"){
            i += 10;
            continue;
        }
        else if (s.substr(i, 10) == "dreamerase"){
            i += 9;
            continue;
        }
        else if (s.substr(i, 6) == "eraser"){
            i += 5;
            continue;
        }
        else if (s.substr(i, 7) == "dreamer"){
            i += 6;
            continue;
        }
        else if (s.substr(i, 5) == "dream"){
            i += 4;
            continue;
        }
        else if (s.substr(i, 5) == "erase"){
            i += 4;
            continue;
        }
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 512
solve n 
    | (r >= 1) && (r <= 6) = 2 * q + 1
    | (r >= 7) && (r <= 10) = 2  * q + 2
    | otherwise = 2 * q
    where
        (q, r) = quotRem n 11

main = do
    n <- readLn :: IO Int
    print $ solve n

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=55;
int a[MAX];
int32_t main()
{
  BOOST;
  int ans=0;
  int n;
  cin>>n;
  for (int i=0;i<n;i++)cin>>a[i];
  while (true){
  	int pos=max_element(a,a+n)-a;
  	if (a[pos]<n)break;
  	for (int i=0;i<n;i++) if (i!=pos)a[i]+=a[pos]/n;
  	ans+=a[pos]/n;
  	a[pos]%=n;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 3600
def is_consistent(bit, testimony):
    all_consistence = True
    for shift in range(n):
        if (bit >> shift) & 1:
            mask, tf = testimony[shift]
            if (bit & mask) != (tf & mask):
                all_consistence = False
    return all_consistence

n = int(input())
testimony = [0] * n
for i in range(n):
    mask, tf = 0, 0
    for j in range(int(input())):
        x, y = map(int, input().split())
        mask += 1 << (x - 1)
        tf += y << (x - 1)
    testimony[i] = (mask, tf)

max_honest = 0
for bit in range(1 << n):
    if is_consistent(bit, testimony) and (max_honest < bin(bit).count('1')):
        max_honest = bin(bit).count('1')
print(max_honest)

Measured memory_bytes: 3064
import java.util.LinkedList;
import java.util.Scanner;



public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int size = sc.nextInt();
		AdjListGraph g = new AdjListGraph(size, true);
		for (int i = 0; i < size; i++){
			int v = sc.nextInt()-1;
			int d = sc.nextInt();
			for(int j=0; j<d; j++){
				g.addEdge(v, sc.nextInt()-1);
			}
		}
		g.BFS(0);
	}

}


class Pair{
	int key;int value;
	Pair(int K, int V){key = K; value = V;}
	int getKey(){return key;}
	int getValue(){return value;}
}	

class AdjListGraph { // http://theoryofprogramming.com/adjacency-list-in-java/
	private boolean digraph;
	private final LinkedList<Pair>[] adjList;
	@SuppressWarnings("unchecked")
	AdjListGraph(int numV, boolean flag){
		adjList = (LinkedList<Pair>[]) new LinkedList[numV];
		for (int i = 0; i < adjList.length; i++) {
			adjList[i] = new LinkedList<>();
		}
		digraph = flag;
	}
	boolean directed(){return digraph;} //return the graph is directed or not
	int getNumOfVertices(){return adjList.length;} //return the num of vertices
	public void addEdge(int startV, int endV, int weight) {
		adjList[startV].add(new Pair(endV, weight));
		if(!digraph){adjList[endV].add(new Pair(startV, weight));}
	} //add an edge to the graph. 
	public void addEdge(int startV, int endV) {
		addEdge(startV, endV, 1); 
	} //weight is set to 1 as a default
	public LinkedList<Integer> getEdgesFromVertexNoWeight(int startV) {
		LinkedList< Integer > edgeList= (LinkedList< Integer >) new LinkedList<Integer>();
		for(Pair pair : adjList[startV]){
			edgeList.add(pair.getKey());
		}
		return edgeList;
	} // get the list of the edges leaving startV. This is for no weight graph. 
	public void print() {
		int i = 0;
		for (LinkedList<Pair> list : adjList) {
			System.out.print("adjList[" + i + "] -> ");
			for (Pair edge : list) {System.out.print(edge.getKey() + "(" + edge.getValue() + ")");}
			i++;
			System.out.println();
		}
	}
	void BFS(int src){
		boolean visited[] = new boolean[getNumOfVertices()];		
		int dist[] = new int[getNumOfVertices()];
		LinkedList<Integer> queue = new LinkedList<Integer>();
		visited[src]=true;	
		queue.add(src);	
		while (queue.size() != 0){
			int tmp = queue.poll();
			LinkedList<Integer> neighbors =  getEdgesFromVertexNoWeight(tmp);
			for(Integer i : neighbors){
				if(!visited[i]){
					visited[i] = true;
					dist[i] = dist[tmp]+1;
					queue.add(i);
				}
			}
		}
		for(int i=0; i< dist.length ; i++){
			if(i!=src && dist[i]==0){
				dist[i]=-1;
			}
		}
		for(int i=0; i< dist.length ; i++){
			System.out.println(Integer.toString(i+1) + " " +  dist[i]);
		}
//		System.out.println(Arrays.toString(dist));
	}
}




Measured memory_bytes: 28428
import java.math.*;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        int cnt = 0;

        for (int i=0; i<n; i+=2) {
            if (arr[i] % 2 == 1) cnt++;
        }

        System.out.print(cnt);

    }


}



Measured memory_bytes: 35768
import sys
import itertools
for line in sys.stdin:
	p, q = map(int, line.split())
	p, r = p / q, p % q * 10
	visited = {}
	visited[r] = 0
	res = ''
	for i in itertools.count(1):
		p, r = r / q, r % q * 10
		res += str(p)
		if r == 0:
			print res
			break
		elif r in visited:
			print res
			n = visited[r]
			print ' ' * n + '^' * (i - n)
			break
		visited[r] = i

Measured memory_bytes: 5912
#include <stdio.h>

int main(){
   int a,b,i;
   char as[10],bs[10];
 
   scanf("%d %d",&a,&b);
   for (i=0;i<a;i++) as[i]='0'+b;
   as[i]='\0';
   for (i=0;i<b;i++) bs[i]='0'+a;
   bs[i]='\0';
   if (as[0]<bs[0]) puts(as);
   else             puts(bs);
   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

    int ans = 0;
    rep(i, n){
        x -= m[i];
        ans++;
    }
    sort(m.begin(), m.end());

    ans += x / m[0];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main (){
    int N;
    std::cin >> N;
    std::string S;
    std::cin >> S;

    for (int i = 0; i < S.size()-1; i++){
        if(S[i]==S[i+1]) N--;
    }
    std::cout << N << "\n";
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

struct Data
{
	int id,p,q,r,c;
};

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<Data> v;
		v.resize(n);

		rep(i,n)
		{
			int id,p,q,r;
			cin >> id >> p >> q >> r;
			v[i].id = id;
			v[i].p = p;
			v[i].q = q;
			v[i].r = r;
			v[i].c = p*4 + q*9 + r*4;
		}

		int P,Q,R,C;
		cin >> P >> Q >> R >> C;

		bool flag = true;
		rep(i,n)
		{
			if(v[i].p <= P && v[i].q <= Q && v[i].r <= R && v[i].c <= C)
			{
				flag = false;
				cout << v[i].id << endl;
			}
		}

		if(flag) cout << "NA" << endl;
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 100000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pii a, pii b)//true for a before b
{
	if(a.S < b.S)
		return 1;
	if(a.S > b.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 900;

int a[N];
vector < pii > res;

void solve()
{
	int n, i, ans = 0;
	cin >> n;
	fo(i,1,n+1)
		cin >> a[i];
	sort(a+1,a+n+1);
	fo(i,2,n)
	{
		if(a[i] >= 0)
		{
			res.pb({a[1],a[i]});
			a[1] -= a[i];
		}
		else
		{
			res.pb({a[n],a[i]});
			a[n] -= a[i];
		}
	}
	res.pb({a[n],a[1]});
	ans = a[n]-a[1];
	cout << ans << '\n';
	for(auto x : res)
		cout << x.F << " " << x.S << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand(clock());

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(6);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main () {
  long L, R;
  cin >> L >> R;
  long modmin = 3000;
  if (R-L+1 >= 2019) {
    modmin = 0;
  } else {
    for (long i = L; i < R; i++) {
      for (long j = i+1; j <= R; j++) {
	long modthis = (i*j)%2019;
	if (modthis < modmin) {
	  modmin = modthis;
	}
      }
    }
  }
  cout<<modmin<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

a_prev = -10
ans = 0
for i in range(N):
    a = A[i] - 1
    ans += B[a]
    if a == a_prev + 1:
        ans += C[a - 1]
    a_prev = a

print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll A,B;
  cin>>A>>B;
  
  ll a=gcd(A,B);
  ll ans=1;
  
  for(ll i=2;i*i<=a;i++){
    bool flag=false;

     while(a%i==0){
       a/=i;
       flag=true;
     }
    
    if(flag){
      ans++;
    }
    if(a==1){
break;
    }

  }
    

       
if(a==1){
  cout<<ans<<endl;
}
else{
  cout<<ans+1<<endl;
}

  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
#define endl "\n"
#define vll vector<ll>
#define ff first 
#define ss second 
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);

int a[100005];
int dp[100005];
int ans =0;
// top down dp 
int solve(int x){
	if(x ==2)return abs(a[2]-a[1]);
	if( x ==3)return  min(solve(2) + abs(a[3]-a[2]), abs(a[3] -a[1]));
	
	if(dp[x] != -1) return dp[x];
	
	int y = x-2, z = x-1;
	return dp[x] = min(abs(a[x] -a[y]) + solve(y), abs(a[x]-a[z]) + solve(z));
}

int main(){
	fastio
	int n;
	cin>>n;
	memset(dp,-1, sizeof(dp));
	for(int i = 1 ;i<=n; i++)cin>>a[i];
	int x = solve(n);
	cout<<x<<endl;
}


Measured memory_bytes: 5760
n = int(input())
s = input()

one = []
zero = []
cnt_one = 0
cnt_zero = 0

if s[0] == "#":
    zero.append(0)

for i in s:
    if i == "#":
        cnt_one += + 1
        if cnt_zero != 0:
            zero.append(cnt_zero)
            cnt_zero = 0
    else:
        cnt_zero += 1
        if cnt_one != 0:
            one.append(cnt_one)
            cnt_one = 0

if cnt_one != 0:
    one.append(cnt_one)
else:
    zero.append(cnt_zero)

if s[-1] == "#":
    zero.append(0)

sum = 0
sum_zero = [0]
for i in range(len(one)):
    sum += zero[len(one)-i]
    sum_zero.append(sum)

sum = 0
sum_one = [0]
for i in range(len(one)):
    sum += one[i]
    sum_one.append(sum)


print(min(sum_one[i] + sum_zero[len(one)-i] for i in range(len(one)+1)))

Measured memory_bytes: 12820
#include <iostream>
#include <queue>
#include <cmath>

using namespace std;
using ll = long long;
using ld = long double;

const int MAXN = 2e5 + 5;

ll dp[MAXN], h[MAXN];

ll f(int j,  int i) {
    return dp[j] + (h[i] - h[j]) * (h[i] - h[j]);
}

ld intersection(int i, int j) {
    return (ld) (f(j, 0) - f(i,  0)) / (2 * (h[j] - h[i]));
    //return (ld) ((h[j] * h[j] + dp[j]) - h[i] * h[i] - dp[i]) / (2 * (h[j] - h[i]));
}

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

    int n;
    ll C;
    cin >> n >> C;
    for (int i = 1; i<= n; i++) {
        cin >> h[i];
    }

    deque<int> Q = {1};
    for (int i = 2; i <= n; i++) {
        while (Q.size() > 1 and intersection(Q[1], Q[0]) < h[i]) {
            Q.pop_front();
        }

        dp[i] = f(Q[0], i) + C;

        while (Q.size() > 1 and intersection(Q[Q.size() - 2], i) <= intersection(Q[Q.size() - 2], Q.back())) {
            Q.pop_back();
        }
        Q.push_back(i);
    }

    cout << dp[n] << "\n";
}


Measured memory_bytes: 3968
import Foundation

func readInts() -> [Int]{
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let nm = readInts()
    let (_,m) = (nm[0],nm[1])
    let votes = readInts().sorted { $0 > $1 }
    let total = votes.reduce(0) { $0 + $1 }
    let counter = votes.filter { $0*4*m >= total }.count
    
    print( counter >= m ? "Yes": "No")
}
main()


Measured memory_bytes: 13668
import sys


MOD = 10 ** 9 + 7
fin = sys.stdin.readline
L = fin().rstrip("\n")

num_bits = len(L)
# prefix_num_comb[i][j][bounded] = L[:i]かつboundedの時かつ和がjで終わる時の組み合わせ
prefix_num_comb = [[[0] * 2 for _ in range(2)] for _ in range(num_bits)]
prefix_num_comb[0][0][False] = 1
prefix_num_comb[0][1][True] = 2

for i in range(1, num_bits):
    bit = L[i]
    if bit == '1':
        prefix_num_comb[i][1][True] = (prefix_num_comb[i - 1][0][True] + prefix_num_comb[i - 1][1][True]) * 2
        prefix_num_comb[i][1][True] %= MOD
        prefix_num_comb[i][0][False] = sum(prefix_num_comb[i - 1][0]) + sum(prefix_num_comb[i - 1][1])
        prefix_num_comb[i][0][False] %= MOD
        prefix_num_comb[i][1][False] = (prefix_num_comb[i - 1][0][False] + prefix_num_comb[i - 1][1][False]) * 2
        prefix_num_comb[i][1][False] %= MOD
    else:
        prefix_num_comb[i][1][False] = (prefix_num_comb[i - 1][0][False] + prefix_num_comb[i - 1][1][False]) * 2
        prefix_num_comb[i][1][False] %= MOD
        prefix_num_comb[i][0][False] = prefix_num_comb[i - 1][0][False] + prefix_num_comb[i - 1][1][False]
        prefix_num_comb[i][0][False] %= MOD
        prefix_num_comb[i][0][True] = prefix_num_comb[i - 1][0][True] + prefix_num_comb[i - 1][1][True]
        prefix_num_comb[i][0][True] %= MOD

print((sum(prefix_num_comb[-1][0]) + sum(prefix_num_comb[-1][1])) % MOD)


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

#define int long long
#define MOD 1000000007

string s;

int pow_mod(int n, int m){
    int ans = 1;
    while(m > 0){
        if(m & 1) ans = (ans * n) % MOD;
        n = (n * n) % MOD;
        m >>= 1;
    }
    return ans;
}

signed main(){
    cin >> s;

    int one_cnt = 0;
    int ans = 0;
    for(int i = 0;i < s.size();i++){
        if(s[i] == '1'){
            ans += (pow_mod(2, one_cnt) * pow_mod(3, s.size()-i-1)) % MOD;
            ans %= MOD;
            one_cnt++;
        }
    }
    ans += pow_mod(2, one_cnt);
    ans %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
n=gets.to_i
a=gets.chomp.split(" ").map(&:to_i)
b=gets.chomp.split(" ").map(&:to_i)
msum=0
a.each do|i|
	msum+=i
end
n.times do|i|
	if(a[i]>b[i])
		a[i]-=b[i]
		b[i]=0
	else
		b[i]-=a[i]
		a[i]=0
		if(i!=n and a[i+1]>b[i])
			a[i+1]-=b[i]
		else
			a[i+1]=0
		end
	end
end
nsum=0
a.each do|i|
	nsum+=i
end
print(msum-nsum)

Measured memory_bytes: 17556
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
#define N 1000005
vector <int> g[N];
int flag[N], f[N], a[N];
int n;
int gcd(int a, int b){
	return (b?gcd(b, a%b):a);
}
int main(){
	for (int i=2;i<N;i++)
		if (!f[i]){
			for (int j=2;j*i<N;j++)
				g[i*j].push_back(i),
				f[i*j]=1;
		}
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	int suf=a[n];
	int pairw=1;
	for (int i=n;i;i--){
		suf=gcd(suf,a[i]);
		if (a[i]==1) continue;
		if (flag[a[i]]) pairw=0;
		if (!pairw) continue;
		flag[a[i]]=1;
		for (int j=0, m=g[a[i]].size();j<m;j++)
			if (flag[g[a[i]][j]]) {pairw=0;break;}
			else flag[g[a[i]][j]]=1;
	}
	if (pairw) printf("pairwise coprime");
	else if (suf==1) printf("setwise coprime");
	else printf("not coprime");
	puts("");
    return 0;
}

Measured memory_bytes: 64812
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin>>n;
    int mx=0;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mx=max(mx,++mp[s]);
    }
    for(const auto &e:mp){
        if(mx==e.second){
            cout<<e.first<<endl;
        }
    }
}


Measured memory_bytes: 25216
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

struct tosi {
	int idnum;
	int p;
	int y;
} ;

int compare_tosi(const void *a, const void *b) {
  struct tosi *A = (struct tosi *)a;
  struct tosi *B = (struct tosi *)b;
  return A->y - B->y;
}



int main(void)
{
	//変数の宣言
	int n,m;
	static int num[100010];
	static int pcopy[100010];
	static int ncopy[100010];
	int i;
	static struct tosi tosis[100010];
	
	
	//データの読み込み
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&tosis[i].p,&tosis[i].y);
		tosis[i].idnum=i+1;
		pcopy[i+1]=tosis[i].p;
	}
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
	qsort(tosis, m, sizeof(struct tosi), compare_tosi);
	
	
//	for(i=0;i<m;i++){
//		printf("idnum=%d p=%d y=%d\n",tosis[i].idnum,tosis[i].p,tosis[i].y);
//	}
	
	
	
	for(i=0;i<m;i++){
		num[tosis[i].p]++;
		ncopy[tosis[i].idnum]=num[tosis[i].p];
//		printf("idnum=%d p=%d ncopy=%d\n",tosis[i].idnum,tosis[i].p,num[tosis[i].p]);
	}
	
//	for(i=1;i<m+1;i++){
//		printf("idnum=%d p=%d ncopy=%d\n",i,pcopy[i],ncopy[i]);
//	}
	
	
	
//	printf("計算部分終了\n");
	
	//出力
	
	for(i=1;i<m+1;i++){
		printf("%06d%06d\n",pcopy[i],ncopy[i]);
	}
	
//	printf("結果の出力終了\n");
	
	return 0;
}

Measured memory_bytes: 3820
unittest
{
	assert( [ "contest", "son" ].parse.expand.solve == 10 );
	assert( [ "contest", "programming" ].parse.expand.solve == -1 );
	assert( [ "contest", "sentence" ].parse.expand.solve == 33 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	input.popFront;
	auto t = input.front.to!( dchar[] );
	return tuple( s, t );
}

auto solve( dchar[] s, dchar[] t )
{
	auto dp = new long[][]( 26, s.length );
	foreach( ref dpp; dp ) dpp[] = -1;
	for( auto ci = 0L; ci < 26; ci++ )
	{
		auto c = cast( dchar )( 'a' + ci );
		foreach_reverse( si, sc; s )
		{
			if( sc == c )
			{
				dp[ ci ][ si ] = 1;
			}
			else if( si + 1 < dp[ ci ].length && 0 < dp[ ci ][ si + 1 ] )
			{
				dp[ ci ][ si ] = dp[ ci ][ si + 1 ] + 1;
			}
		}
	}
	
	auto ans = 0L;
	foreach( tc; t )
	{
		auto si = ans % s.length;
		auto ci = cast( long )( tc - 'a' );
		
		if( 0 <= dp[ ci ][ si ] )
		{
			ans += dp[ ci ][ si ];
		}
		else
		{
			if( dp[ ci ][ 0 ] == -1 ) return -1;
			ans += s.length.signed - si + dp[ ci ][ 0 ];
		}
	}
	return ans;
}


Measured memory_bytes: 23960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  
  ll ans;
  if(a%x == 0){
    ans = (b-a)/x + 1;
  }else{
    ans = b/x - a/x;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace CSharpTest
{
    class C_Gacha
    {
        static void Main(string[] args)
        {
            var Seed = new Dictionary<string, bool>();
            Int64 N = Int64.Parse(Console.ReadLine());
            for(Int64 i = 0;i < N; i++)
            {
                string NSeed = Console.ReadLine();
                if (!(Seed.ContainsKey(NSeed))) Seed.Add(NSeed,true);
            }
            Console.WriteLine(Seed.Count);
        }
    }
}


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

int main() {
    int x;
    cin >> x;
    int i =1;
    int r = 360 % x;
    while(r != 0){
        i++;
        r = 360 * i % x;
    }
    int k = 360 * i / x;
    cout << k << endl;
}

Measured memory_bytes: 3592
import java.util.*;
import java.io.*;

public class Main {
	static class Node {
		int notNIL = 1;
		int id = -1;
		Node parent = NIL;
		Node left = NIL;
		Node right = NIL;
		Node sibling = NIL;
		int degree;
		int depth = -2;
		int height = -2;
	}
	static Node NIL = new Node();
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		Node[] tree = new Node[n + 1];
		NIL.notNIL = 0;
		NIL.depth = -1;
		NIL.height = -1;
		tree[0] = NIL;
		for (int i = 1; i < n + 1; i ++) {
			tree[i] = new Node();
		}

		for (int i = 0; i < n; i ++) {
			int id = scanner.nextInt();
			Node u = tree[id + 1];
			u.id = id;
			
			Node left = tree[scanner.nextInt() + 1];
			u.left = left;
			left.parent = u;
			
			Node right = tree[scanner.nextInt() + 1];
			u.right = right;
			right.parent = u;
			
			left.sibling = right;
			right.sibling = left;
			
			u.degree = left.notNIL + right.notNIL;
		}

		scanner.close();
		
		for (int i = 1; i < n + 1; i ++) {
			Node u = tree[i];
			System.out.print("node ");
			System.out.print(u.id);
			System.out.print(": parent = ");
			System.out.print(u.parent.id);
			System.out.print(", sibling = ");
			System.out.print(u.sibling.id);
			System.out.print(", degree = ");
			System.out.print(u.degree);
			System.out.print(", depth = ");
			System.out.print(getDepth(u));
			System.out.print(", height = ");
			System.out.print(getHeight(u));
			System.out.print(", ");
			System.out.println((u.parent == NIL) ? "root": ((u.degree != 0) ? "internal node": "leaf"));
		}
	}
	
	static int getDepth(Node u) {
		if (u.depth != -2) return u.depth;
		u.depth = getDepth(u.parent) + 1;
		return u.depth;
	}
	
	static int getHeight(Node u) {
		if (u.height != -2) return u.height;
		u.height = Math.max(getHeight(u.left), getHeight(u.right)) + 1;
		return u.height;
	}
} 



Measured memory_bytes: 26452
#include <iostream>
using namespace std;
int main() {
    long n;
    long a[10000];
    int ans = 0;
    cin >> n;
    for (int i = 0; i < n ; ++i) {
        cin >> a[i];
        int check = 0;
        for (int j = 1; j * j <= a[i] ; ++j) {
            if( a[i] % j == 0) check++;
        }
        if(check == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

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


int main(){
	int a, b;
	cin >> a >> b;
	bool flag = false;
	if(a%3 == 0 && a) flag = true;
	if(b%3 == 0 && b) flag = true;
	if((a+b)%3 == 0 && (a+b)) flag = true;
	cout << (flag ? "Possible\n" : "Impossible\n");
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
    int k; scanf("%d",&k);
    bool used[100010]={};
    deque<pair<int,int>> deq; deq.push_back({1,1});
    while(deq.size()){
        auto p=deq.front(); deq.pop_front();
        int v=p.first,d=p.second; 
        if(used[v])continue; used[v]=1;
        if(!v){printf("%d\n",d); return 0;}
        deq.push_back({(v+1)%k,d+1});
        deq.push_front({(10*v)%k,d});
    }
    return 0;
}

Measured memory_bytes: 1152
from operator import itemgetter
N = int(input())
A = [tuple(map(int,input().split())) for i in range(N)]
B = [tuple(map(int,input().split())) for i in range(N)]
A.sort()
B.sort()
num = 0
for i in range(N):
    K = [A[k] for k in range(len(A)) if (A[k][0] <B[i][0]) and (A[k][1] < B[i][1])]
    if K:
        num += 1
        t = sorted(K, key=itemgetter(1))[-1]
        A.remove(t)
print(num)

Measured memory_bytes: 39152
n, k = map(int,input().split())
s = input()
l = [0]
for i in range(n-1):
    if s[i+1] != s[i]:
        l.append(i+1)
l.append(n)

ans = 0
for i in range(len(l)-1):
    ind = min(i+2*k + int(s[l[i]]=="1"), len(l) - 1)
    ans = max(ans, l[ind] - l[i])

print(ans)

Measured memory_bytes: 7156
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n, m;
	cin >> n >> m;

	int ans = m;
	rep(i, n) {
		int a, b;
		cin >> a >> b;

		m += a;
		m -= b;

		if(m < 0) {
			ans = 0;
			break;
		}
		else ans = max(ans, m);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define INF 1e9
using ll = std::int64_t;

template <class T>
bool chmax(T &a, const T &b);
template <class T>
bool chmin(T &a, const T &b);
//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b);
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb);
//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str);
//素数判定
bool is_prime(std::int64_t n);
// 約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n);
// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n);

//10^9 + 7
#define yojo 1000000007
#define MAX_NUM 200001

void Main()
{
  int n, d, x;
  int a[200];
  cin >> n >> d >> x;
  rep(i, n) cin >> a[i];

  int count = x;
  rep(i, n){
    count += ((d - 1) / a[i]) + 1;
  }

  std::cout << count << std::endl;

  return;
}

int main()
{
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return true;
  }
  return false;
}

//最大公約数
std::int64_t gcd(std::int64_t a, std::int64_t b)
{
  // a >= b && b != 0
  std::int64_t c;
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//最大公約数安全版
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb)
{
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0)
  {
    return -1;
  }
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}

//ラングレス圧縮
std::vector<std::pair<char, std::int64_t>> rle(std::string str)
{
  std::vector<std::pair<char, std::int64_t>> data;
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++)
  {
    if (i == str.size())
    {
      data.push_back(make_pair(str[i - 1], count));
      break;
    }
    else if (now != str[i])
    {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return data;
}

//素数判定
bool is_prime(std::int64_t n)
{
  for (std::int64_t i = 0; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      return false;
    }
  }

  return n != 1;
}

//約数の列挙
std::vector<std::int64_t> divisor(std::int64_t n)
{
  std::vector<std::int64_t> res;
  for (int i = 0; i < n; i++)
  {
    if (n % i == 0)
    {
      res.push_back(i);
      if (i != n / i)
        res.push_back(n / i);
    }
  }
  return res;
}

// 素因数分解
std::map<std::int64_t, std::int64_t> prime_factor(std::int64_t n)
{
  std::map<std::int64_t, std::int64_t> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ++res[i];
      n /= i;
    }
  }

  if (n != 1)
  {
    res[n] = 1;
  }

  return res;
}


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

const int N = 1e5 + 5;
int n, a, b;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> a >> b;
    
    cout << min(n*a, b) << "\n";
    
    
    return 0;
}


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

using namespace std;

int main()
{
    int n,x;
    cin >> n >> x;
    
    int cnt=0;
    int length=0;
    for(int i=0;i<=n;i++){
        if(length<=x){
            cnt++;   
        }
        int l;
        cin >> l;
        length+=l;
    }

    cout << cnt << endl;
}

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

for i in range(1,N+1):

    if i%3 == 0:
            print(" %d"%i,end = "");
    else:
        x = i
        while (x):
            if x%10 == 3:
                print(" %d"%i,end = "")
                break
            x //= 10
print()


Measured memory_bytes: 5872
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

D, T, S = map(int, input().split())
if T * S >= D:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 10652
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 8787;
double dp[MAXN][MAXN], tmp[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    dp[0][0] = 1.0;
    for (int i = 1; i <= N; i++) {
        double p;
        scanf("%lf", &p);
        for (int j = 0; j <= i; j++) tmp[j] = dp[i - 1][j];
        for (int j = 0; j <= i; j++) {
            dp[i][j] = tmp[j] * (1.0 - p);
            if (j) dp[i][j] = dp[i][j] + (tmp[j - 1] * p);
        }
    }
    double ans = 0.0;
    for (int i = 0; i <= N; i++) {
        if (i > N / 2) ans += dp[N][i];
    }
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 205184
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
//計算量はどちらもO(logN)
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;}
 
LL K;
 
LL ans = 0;
 
void solve(){
	for(LL a=1;a<=K;a++){
		for(LL b=1;b<=K;b++){
			for(LL c=1;c<=K;c++){
				ans += gcd(a,gcd(b,c));
			}
		}
	}
}
 
int main(){
    cin >> K;
 
    solve();
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <cstdio>
using namespace std;
char map[100][100];
int H, W, D, sum;

void solve(int x, int y) {
    bool flag;
    if (x+D-1 < H) {
        flag = true;
        for (int i = x; i < x+D; i++) if (map[i][y] == '#') { flag = false; break; }
        if (flag) sum++;
    }
    if (y+D-1 < W) {
        flag = true;
        for (int i = y; i < y+D; i++) if (map[x][i] == '#') { flag = false; break; }
        if (flag) sum++;
    }
}

int main() {
    scanf("%d %d %d", &H, &W, &D);
    sum = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) scanf(" %c", &map[i][j]);
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) if (map[i][j] == '.') solve(i, j);
    }
    printf("%d\n", sum);
    return 0;
}



Measured memory_bytes: 2708
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String O = sc.next();
		String E = sc.next();
		for(int i = 0; i < O.length() - 1; i++) {
				char o = O.charAt(i);
				char e = E.charAt(i);
				System.out.print(o);
				System.out.print(e);
		}
		System.out.print(O.charAt(O.length() -1));
		if(E.length() == O.length()) System.out.println(E.charAt(E.length() - 1));
	}
		
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    class mato{
        public int h, r;
        public mato(int h, int r) {
            this.h = h; this.r = r;
        }
        public bool interMid(mato m1, mato m2){
            if (m1.h < h && m1.r < r && h < m2.h && r < m2.r) { return true; }
            return false;
        }
        public bool bigger(mato m1) {
            return (m1.h < h && m1.r < r);
        }
    }



    class ClassMain {



       

        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                if(n==0){break;}
                List<mato> mlis = new List<mato>();
                
                for (int i = 0; i < n; i++) {
                    int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    mlis.Add(new mato(ints[0],ints[1]));
                }
                int m = int.Parse(Console.ReadLine());

                for (int i = 0; i < m; i++) {
                    int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    mato mat = new mato(ints[0], ints[1]);
                    for (int j = 0; j < mlis.Count ; j++) {
                        if (j != mlis.Count - 1) {
                        //inter mid
                            if(mat.interMid(mlis.ElementAt(j),mlis.ElementAt(j+1))){
                                mlis.Insert(j+1,mat);
                                break;
                            }
                        }else{
                            //last
                            if(mat.bigger(mlis.ElementAt(mlis.Count-1))){
                                mlis.Add(mat);
                                break;
                            }
                        }
                    }                
                }
                Console.WriteLine(mlis.Count);


            }
        }
    
    }



    
}

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

int main(){

    int n,k,h;
    int cnt;
    cin>>n>>k;

    for(int i=0;i<n;i++){
        cin>>h;
        if(h>=k) cnt++;
    }
    cout<<cnt<<endl;






    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
	int w,h,x,y,flag=0;
	scanf("%d %d %d %d",&w,&h,&x,&y);
	
	if(((double)w)/2 == x && ((double)h)/2 == y) flag=1;
	printf("%lf %d\n",((double)w*(double)h)/2,flag);
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <cstring>
#include <sstream>
#include <string>
#include <iostream>
using namespace std;

typedef pair<int,int> pii;

inline int dist(const pii &p, const pii &q){
	return abs(p.first - q.first) + abs(p.second - q.second);
}

void input(int &w, int &h, vector<vector<int> > &v){
	string s;
	v.clear();
	v.resize(h);
	for(int i = 0; i < h; ++i){
		vector<int> &t = v[i];
		getline(cin, s);
		stringstream ss(s);
		while(ss >> s){
			if(s[0] == '.'){
				t.push_back(-1);
			}
			else if(s[0] == 'S'){
				t.push_back(-2);
			}
			else if(s[0] == 'G'){
				t.push_back(-3);
			}
			else{
				t.push_back(strtol(s.c_str(), 0, 10));
			}
		}

		if(t.size() != w){
			if(i != 0){
				throw 0;
			}
			swap(h, w);
			v.resize(h);
		}
	}
}

int main(){
	const int INF = 1000000000;
	int w, h, x;
	char ch;
	vector<vector<int> > in;
	string str;
	while(getline(cin, str) && sscanf(str.c_str(), "%d%d", &w, &h) == 2 && w){
		map<int,vector<pii> > mp;
		map<int,vector<pii> >::iterator it1, it2;
		input(w, h, in);
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				if(in[i][j] >= 0){
					mp[in[i][j]].push_back(pii(i, j));
				}
				else if(in[i][j] == -2){
					mp[0].push_back(pii(i, j));
				}
				else if(in[i][j] == -3){
					mp[INF].push_back(pii(i, j));
				}
			}
		}

		vector<int> dp1(1, 0), dp2;
		it1 = it2 = mp.begin();
		while(++it2 != mp.end()){
			dp2.assign(it2->second.size(), INF);
			for(int i = 0; i < it1->second.size(); ++i){
				pii p1 = it1->second[i];
				for(int j = 0; j < it2->second.size(); ++j){
					pii p2 = it2->second[j];
					dp2[j] = min(dp2[j], dp1[i] + dist(p1, p2));
				}
			}
			dp1.swap(dp2);
			++it1;
		}
		printf("%d\n", dp1[0]);
	}
}

Measured memory_bytes: 1536
#include<stdio.h>

int main()
{
    char ch[10];
    scanf("%s",ch);
    if(ch[0]=='S')
        printf("Cloudy\n");
    else if(ch[0]=='C')
        printf("Rainy\n");
    else
        printf("Sunny\n");

    return 0;
}


Measured memory_bytes: 1580
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if ((a * b) > (c * d))
            System.out.println(a * b);
        else
            System.out.println(c * d);
    }
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0, f = n;
  while(f>0) {
    ans += (f%10);
    f = f/10;
  }
  cout << (n%ans == 0 ? "Yes" : "No") << endl; 
  return 0;
}

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

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		double r = Double.parseDouble(br.readLine());
		double pi = Math.PI;
		double x = r*r*pi;
		double y = 2*r*pi;
		System.out.printf("%.6f %.6f",x,y);
	}
}

Measured memory_bytes: 17080
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x is not None: x, y = x.left if key < x.key else x.right, x
    if y is None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result is None

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 55684
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		int[] s = new int[5000];
		int[] m = new int[5000];
		int n,t,x;
		while((n=Integer.parseInt(bf.readLine()))!=0){
			for(int i=0;i<n;i++){
				s[i]=m[i]=t=Integer.parseInt(bf.readLine());
				for(int j=0;j<i;j++){
					s[j]+=t;
					if(m[j]<s[j])m[j]=s[j];
				}
			}
			x=m[0];for(int i=1;i<n;i++)if(x<m[i])x=m[i];
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 11000
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]*(N+1)
b = [0]*(M+1)

#累積和の計算
for i in range(1, N+1):
    a[i] = a[i-1] + A[i-1]
for j in range(1, M+1):
    b[j] = b[j-1] + B[j-1]

ans = 0
# j = M
for i in range(N+1):
#     left = 0
#     right = j
    if K - a[i] < 0:
        break
#     while left < right:
#         mid = (left + right)//2
#         if b[mid] < K - a[i]:
#             left = mid + 1
#         elif b[mid] > K - a[i]:
#             right = mid - 1
#     if b[left] <= K - a[i]:
#         j = left
#     else:
#         j = left - 1
    j = bisect.bisect_right(b, K - a[i]) - 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47432
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;

int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

int main() {
    int N; cin >> N;
    vector<vector<int> > hyou(N + 1, vector<int>(N + 1, -1));
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        for(int j = 0; j < a; j++) {
            int x, y; cin >> x >> y;
            hyou[i+1][x] = y;
        }
    }

    int ans = 0;
    for (int i = 0; i < pow(2, N); i++) {
        std::stringstream ss;
        ss << std::bitset<15>(i);
        std::string s = ss.str();
        reverse(s.begin(), s.end());
        int t = 0;
        for (int j = 0; j < N; j++) {
            if (s[j] - '0' == 1) t++;
        }
        bool f = true;
        for (int j = 1; j < N+1; j++) {
            if (s[j-1] - '0' == 1) {
                for (int k = 0; k < N+1; k++) {
                    if (hyou[j][k] != -1 && s[k-1] - '0' != hyou[j][k]) {
                        f = false;
                        break;
                    }
                }
            }
            if (!f) break;
        }
        if (f) ans = max(ans, t);
    }
    std::cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n,m;
    cin >> n >> m;
    int a[n],b[n];
    REP(i,n){
        cin >> a[i] >> b[i];
    }
    int c[m],d[m];
    REP(i,m){
        cin >> c[i] >> d[i];
    }
    REP(i,n){
        int mn = INF;
        int ans;
        REP(j,m){
            if(abs(a[i] - c[j]) + abs(b[i] - d[j]) < mn){
                mn = abs(a[i] - c[j]) + abs(b[i] - d[j]);
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256