akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> P;

int main(){
	ios::sync_with_stdio(false);

	int p, q;
	while (cin >> p >> q, p){
		map<vector<int>, int> m;
		vector<int> cnt(3);
		while(p--){
			string s;
			cin >> s;
			int x = 0;
			while (s[x] == '.') x++;
			m[cnt] = x;
			rep(i, s.size()){
				rep(j, 3) if (s[i] == "({["[j]) ++cnt[j];
				rep(j, 3) if (s[i] == ")}]"[j]) --cnt[j];
			}
		}

		vector<vector<int>> cand;
		FOR(R, 1, 21) FOR(C, 1, 21) FOR(S, 1, 21){
			bool ok = true;
			for (auto &v : m){
				int dot = 0;
				dot += v.first[0] * R;
				dot += v.first[1] * C;
				dot += v.first[2] * S;
				if (dot != v.second) ok = false;
			}
			if (ok) cand.push_back({ R, C, S });
		}
		cnt = vector<int>(3);
		vector<int> ans;
		while(q--){
			string s;
			cin >> s;

			if (m.count(cnt)){
				ans.push_back(m[cnt]);
			}
			else{
				set<int> icand;
				for (auto &t : cand){
					int sum = 0;
					rep(i, 3) sum += cnt[i]*t[i];
					icand.insert(sum);
				}
				if (icand.size() == 1){
					ans.push_back(*icand.begin());
				}
				else{
					ans.push_back(-1);
				}
			}

			rep(i, s.size()){
				rep(j, 3) if (s[i] == "({["[j]) ++cnt[j];
				rep(j, 3) if (s[i] == ")}]"[j]) --cnt[j];
			}
		}

		rep(i, ans.size()){
			cout << (i ? " " : "") << ans[i];
		}cout << endl;
	}

	return 0;
}

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

int main(){
    string x;
    int sum;
    vector<int> o;

    while (true)
    {
        cin >> x;
        if(x.size()==1 && x.at(0)-'0'==0) break;
        sum=0;
        for (int i = 0; i < x.size(); i++)
        {
            sum += x.at(i) - '0';
        }
        o.push_back(sum);
    }
    
    for (int i = 0; i < o.size(); i++)
    {
        cout << o.at(i) << endl;
    }
    
}


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

stack<char>alice,bob,charlie;

int f(char c){
    if(c=='a') return 1;
    if(c=='b') return 2;
    if(c=='c') return 3;
}

int main(){
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    for(int i=s1.size()-1;i>=0;i--) alice.push(s1[i]);
    for(int i=s2.size()-1;i>=0;i--) bob.push(s2[i]);
    for(int i=s3.size()-1;i>=0;i--) charlie.push(s3[i]);
    char c=alice.top();
    alice.pop();
    while(true){
        int temp=f(c);
        if(temp==1) {
            if(alice.empty()) {
                printf("A\n");
                break;
            }
            c=alice.top();
            alice.pop();
        }
        else if(temp==2){
            if(bob.empty()){
                printf("B\n");
                break;
            }
            c=bob.top();
            bob.pop();
        }
        else {
            if(charlie.empty()){
                printf("C\n");
                break;
            }
            c=charlie.top();
            charlie.pop();
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 10
#define WHITE 0
#define BLACK 1

bool L[MAX][MAX];
int color[MAX];
int N,M,ans;


void dfs(int s){
  int count=0;
  for(int i=0;i<N;i++){
    if(color[i]==BLACK) count++;
  }
  if(count==N) {
    ans++; return;
  };

  
  for(int i=1;i<N;i++){
    if(L[s][i]==false) continue;
    if(color[i]==BLACK) continue;
    color[i]=BLACK;
    dfs(i);
    color[i]=WHITE;
  }
  return;
}

int main(){
  for(int i=0;i<MAX;i++){
    for(int k=0;k<MAX;k++){
      L[i][k]=false;
    }
  }
  int a,b;
  cin>>N>>M;
  for(int i=0;i<M;i++){
    cin>>a>>b;
    a--; b--;
    L[a][b]=true;
    L[b][a]=true;
  }
  color[0]=BLACK;
  dfs(0);
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
import math
def is_prime(n):
    if n % 2 == 0 and n > 2: 
        return False
    return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))
                      
while True:
    try:
        n = int(raw_input())
        total = 0
        for k in range(n):
            if is_prime(int(raw_input())):
                total +=1
        print total
    except EOFError:
        break    

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

int kp(int n, int x){
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(x - i - j > j && x - i - j <= n) cnt++;
        }
    }
    return cnt;
}
int main(){
    while(true){
        int n, x; cin >> n >> x;
        if(n == 0 && x == 0) break;
        cout << kp(n, x) << endl;
    }
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   IOS;
   int n;
   cin >> n;
   ll ans = 0;
   rep(i,1,n)
   {
       ans += (ll)i*(n-i+1);
   }
   rep(i,1,n-1)
   {
       int u,v;
       cin >> u >> v;
       if(u > v)swap(u,v);
       ans -= (ll)u*(n-v+1);
   }
   cout << ans;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define MOD 1000000007
#define pb push_back
#define ll long long int

using namespace std;

int main(void) {
    fast;
    string a, b; cin >> a >> b;
    int ans=0;
    for(int i=0; i<a.size(); ++i) {
        if (a[i] != b[i]) {
            ans -=- 1;
        }
    }
    cout << ans;
}



Measured memory_bytes: 3804
//nugget in a biscuit DIP IT ON 'MASH POTATO
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef long long ll;
typedef double w;
typedef string s;
int main(){
    ll a,b,t,z,k;
    cin>>a>>b>>t;
    z=(t/a)*b;
    cout<<z;
return 0;}


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

int main()
{
	int L,A,B,C,D,a=0,b=0;
	cin >> L >> A >> B >> C >> D;

	a = A/C;
	if(A%C>0){
	a++;	
	}
	b = B/D;
	if(B%D>0){
	b++;
	}

	if(a>b){
		cout << L-a << "\n";
	}else{
		cout << L-b << "\n";
	}
	return 0;
}

Measured memory_bytes: 1164
N=int(input())
ac=0
wa=0
tle=0
re=0
for _ in range(N):
  s=input()
  if 'AC'==s:
     ac+=1
  elif 'WA'==s:
    wa+=1
  elif 'TLE'==s:
    tle+=1
  elif 'RE'==s:
    re+=1
print('AC','x',ac)
print('WA','x',wa)
print('TLE','x',tle)
print('RE','x',re)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
 
    // dp[i][j] = max value of first i blocks with weight <= j
    int n;
    cin >> n;
    using block = tuple<int, int, int, int>;
    vector<block> blocks;
    int max_w = 0;
    int max_s = 0;
    for (int i = 0; i < n; ++i) {
        int w, s, v;
        cin >> w >> s >> v;
 
        max_w = max(max_w, w);
        max_s = max(max_s, s);
        blocks.emplace_back(w + s, w, s, v);
    }
    sort(all(blocks));
 
    int cap = max_s + max_w;
    // now run the dp
    vector<vector<ll>> dp(n + 1, vector<ll>(cap + 1, 0LL));
 
    for (int i = 0; i < n; ++i) {
        int ws, w, s, v;
        tie(ws, w, s, v) = blocks[i];
        for (int j = 0; j <= cap; ++j) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j <= s && j + w <= cap) {
                dp[i + 1][j + w] = max(dp[i + 1][j + w], dp[i][j] + v);
            }
        }
    }
 	ll ans =0;
 	for(int j = 0;j<=cap;j++)
	 	ans = max(ans,dp[n][j]);
	cout << ans << '\n';
    return 0;
}

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

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

	int train[10];
	int v1, v2;
	char c;

	while(cin >> train[0] >> c){
		int sum = 0;
		sum += train[0];
		for(int i = 1; i < 10; ++i){
			cin >> train[i] >> c;
			sum += train[i];
		}

		cin >> v1 >> c >> v2;

		float t = (float)sum / (v1 + v2);
		float l = v1 * t;

		int i = 0;
		while(l > 0){
			l -= train[i];
			++i;
		}

		cout << i << endl;
	}

	return 0;
}

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

int main(){
    int K, S;
    cin >> K >> S;
    int count = 0;
    for(int i = 0; i <= K; i++){
        for(int j = 0; j <= K; j++){
            int z = S - (i + j);
            if(z < 0 || z > K) continue;
            count++;
        }
    }

    cout << count << endl;

    return 0;
}



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


int main(){
  string s,t;
  cin >> s >> t;
  bool ok=false;
  for(int i=0;i<s.size();++i){
    if(s==t){
      ok=true;
      break;
    }
    s=s[s.size()-1]+s.substr(0,s.size()-1);
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a<1 || a>9)
	{
		cout<<"-1"<<endl;
		return 0;
	}
	if(b<1 || b>9)
	{
		cout<<"-1"<<endl;
		return 0;
	}
	cout<<a*b<<endl;
	return 0;
}

Measured memory_bytes: 256
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    input += chunk;
});
process.stdin.on('end', function() {
    var lines = input.split('\n').map(Number);
    for (var i = 0; i < lines.length && lines[i] != 0; i++) {
        console.log('Case %d: %d', i + 1, lines[i]);
    }
});


Measured memory_bytes: 23924
#include <stdio.h>
#include <stdlib.h>
#include <string.h>



void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atoi(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atoi(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}

int main(void) {

int input1[120];
inp_str(input1);

int input2[120];
inp_str(input2);

int N,M,C;
N=input1[0];

M=0;
C=0;

int i;
for(i=0;i<N;i=i+1){
if(input2[i]>=M){
	M=input2[i];
	C=C+1;
}

}



//printf("%d\n",M);

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




/*

if(flag==1) {
	printf(":(\n");
}else{
printf("Yay!\n");
} 

*/                       
    return 0;
}


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

#define N 1000000
#define L 12

int insert(char *);
int hash1(int);
int hash2(int);
int find(char *);
long long getkey(char *);
char H[N][L];

int main() {
  int i,n,h;
  char str[L],com[9];
  for(i = 0;i < N;i++){
    H[i][0]='\0';
  }
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%s%s",com,str);

    if(com[0] == 'i'){
      insert(str);
    }else {
      if(find(str)){
        printf("yes\n");
      }
      else{
        printf("no\n");
      }
    }
  }
  return 0;
}

int A(char ch){
  if(ch == 'A'){
    return 1;
  }
  else if(ch == 'C'){
    return 2;
  }
  else if(ch == 'G'){
    return 3;
  }
  else if(ch == 'T'){
    return 4;
  }
  else return 0;
}

long long getkey(char str[]){
  long long sum=0,p=1,i;
  for(i = 0;i < strlen(str);i++){
    sum += p*(A(str[i]));
    p *= 5;
  }
  return sum;
}

int hash1(int key){
  return key % N;
}

int hash2(int key){
  return 1+(key%(N-1));
}

int find(char str[]){
  long long key,i,h;
  key = getkey(str);
  for(i = 0;;i++){
    h = (hash1(key)+i*hash2(key))%N;
    if(strcmp(H[h],str)==0){
      return 1;
    }
    else if(strlen(H[h])==0){
      return 0;
    }
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getkey(str);
  for(i = 0;;i++){
    h=(hash1(key)+i*hash2(key))%N;
    if(strcmp(H[h],str)==0){
      return 1;
    }
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;

    }
  }
  return 0;
}



Measured memory_bytes: 13472
n = gets.to_i
a = gets.split.map(&:to_i)
gets; m = gets.split.map(&:to_i)

list = {}
1.upto(n) do |i|
  a.combination(i).each {|e| list[e.inject(:+)] = nil}
end
m.each do |e|
  puts list.key?(e) ? 'yes' : 'no'
end

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

int main()
{
    int N, Y;
    cin >> N >> Y;

    bool isFound = false;
    int ni = -1;
    int nj = -1;
    int nk = -1;
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= N - i; j++)
        {
            int k = N - i - j;
            int x = 10000 * i + 5000 * j + 1000 * k;
            if (x == Y)
            {
                ni = i;
                nj = j;
                nk = k;
                isFound = true;
                break;
            }

            if (isFound)
            {
                break;
            }
        }
        if (isFound)
        {
            break;
        }
    }

    cout << ni << " " << nj << " " << nk << endl;

    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>

using namespace std;

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

  if (s.length() == 2) {
    cout << s << endl;
  } else {
    reverse(s.begin(), s.end());
    cout << s << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
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; }
//#define int long long

void solve() {
	int n, k; cin >> n >> k;
    string s; cin >> s;
    int cnt = 0;
    rep(i, n) {
        if(s[i] == 'L') {
            if(i == 0 || s[i - 1] == 'R') cnt ++; 
        } else {
            if(i == n - 1 || s[i + 1] == 'L') cnt ++;
        }
    }
    if(cnt - 1 <= 2 * k) {
        cout << n - 1 << endl;
        return;
    } else {
        cout << n - cnt + 2 * k << endl;
        return;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int n, b, f, r, v, i, j, k;
	int house[4][3][10] = {0};
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		house[b - 1][f - 1][r - 1] += v;
	}
	
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 10; k++) {
				printf(" %d", house[i][j][k]);
			}
			printf("\n");
		}
		if (i != 3){
			printf("####################\n");
		}
	}
	
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b;
char c;

int main() {
	cin >> a >> c >> b;
	
	cout << (c == '+' ? a + b : a - b) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int counter[3] = {0};
		int Ocounter[3] = {0};
		int h, m, mm;
		char c;
		for (int i = 0; i < n; i++) {
			cin >> h >> c >> m >> mm;
			if (m > mm) {
				mm += 60;
			}
			if (11 <= h && h <= 14) {
				counter[0]++;
				if (mm-m <= 8) {
					Ocounter[0]++;
				}
			} else if (18 <= h && h <= 20) {
				counter[1]++;
				if (mm-m <= 8) {
					Ocounter[1]++;
				}
			} else if (21 <= h || h <= 1) {
				counter[2]++;
				if (mm-m <= 8) {
					Ocounter[2]++;
				}
			} else {
			}
		}
		cout << "lunch ";
		if (counter[0] == 0) {
			cout << "no guest" << endl;
		} else {
			int a = (double)Ocounter[0]/(double)counter[0]*100.0;
			cout << a << endl;
		}
		cout << "dinner ";
		if (counter[1] == 0) {
			cout << "no guest" << endl;
		} else {
			int a = (double)Ocounter[1]/(double)counter[1]*100.0;
			cout << a << endl;
		}
		cout << "midnight ";
		if (counter[2] == 0) {
			cout << "no guest" << endl;
		} else {
			int a = (double)Ocounter[2]/(double)counter[2]*100.0;
			cout << a << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
n,a,b=gets.chomp.split(" ").map { |e| e.to_i }

def sum_number(s)
  s=s.to_s
  leng = s.length
  sum = 0

  for i in 0..leng-1 do
    sum += s[i].to_i
  end
  return sum
end

sum = 0

for i in 1..n do
  x=sum_number(i)
  if  a<=x && x<=b
      sum += i
  end
end

puts sum

Measured memory_bytes: 1788
n = gets.to_i
tc, xc, yc = [0, 0, 0]

ans = "Yes"

n.times do |i|
  tn, xn, yn = gets.split.map(&:to_i)

  t = tn - tc
  x = (xn - xc).abs
  y = (yn - yc).abs

  if x + y > t
    ans = "No"
    break
  end

  t -= (x + y)
  if t.odd?
    ans = "No"
    break
  end

  tc, xc, yc = tn, xn, yn
end

puts ans


Measured memory_bytes: 1788
# coding: utf-8
n = int(input())
pt_min = 10 ** 9 + 1
rank_lowest = 0

for i in range(n):
    a, b = map(int, input().split())
    if b < pt_min:
        pt_min = b
        rank_lowest = a

# ans = pt_min + 1 + rank_low - rank_high + rank_high - 1
print(pt_min + rank_lowest)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
 
int main(){
  ll i,j,k,N,M,L,cnt,ans=0;
  cin>>N>>M;
  mat v(M);
  pvec x(N);
  rep(i,N){
    cin>>x[i].second;
    x[i].first=x[i].second%M;
  }
  vsort(x);
  rep(i,N){
    v[x[i].first].push_back(x[i].second);
  }
  L=M/2+1;
  rep(i,L){
    j=(M-i)%M;
    if(i==j){
      cnt=v[i].size()/2;
      ans+=cnt;
      continue;
    }
    cnt=0;
    if(v[i].size()<v[j].size()){
      rep(k,(ll)v[j].size()-1){
        if(v[j][k]==v[j][k+1]){
          cnt++;
          k++;
        }
      }
      k=(v[j].size()-v[i].size())/2;
      ans+=v[i].size()+min(cnt,k);
    }else{
      if(v[i].size()==0)continue;
      rep(k,(ll)v[i].size()-1){
        if(v[i][k]==v[i][k+1]){
          cnt++;
          k++;
        }
      }
      k=(v[i].size()-v[j].size())/2;
      ans+=v[j].size()+min(cnt,k);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7296
N = int(input())
h = list(map(int,input().split()))

dp = [0]*N
dp[1] = abs(h[0] -h[1])

for i in range(2,N):
	dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),dp[i-2] + abs(h[i] - h[i-2]) )
print(dp[-1])

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

int main() {
    int A, B;
    std::cin >> A >> B;
    std::string S;
    std::cin >> S;

    bool cond1 = S[A] == '-';
    bool cond2 = std::all_of(S.begin(), S.begin() + A,
                             [](char c) { return std::isdigit(c); });
    bool cond3 = std::all_of(S.begin() + A + 1, S.end(),
                             [](char c) { return std::isdigit(c); });
    std::cout << (cond1 && cond2 && cond3 ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
const int MAX = 1e5+1;

int main(void){
	int N,C;
	cin >> N >> C;
	vector<int> s(N),t(N),c(N);
	rep(i,N){
		cin >> s[i] >> t[i] >> c[i];
		c[i]--;
	}
	vector<int> table(MAX+1);
	for(int i=0;i<C;i++){
		vector<int> dp(MAX+1);
		for(int j=0;j<N;j++)if(c[j]==i){
			dp[s[j]]++;
			dp[t[j]+1]--;
		}
		for(int j=0;j<MAX-1;j++)dp[j+1] += dp[j];
		for(int j=0;j<MAX;j++)if(dp[j])table[j]++;
		//for(int j=0;j<15;j++)cout << dp[j] << " ";
	}
	int mx = 0;
	for(int j=0;j<MAX;j++){
		mx = max(mx,table[j]);
	}
	cout << mx << endl;
}

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

using namespace std;

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    if(x == 1 || x == 2 * n - 1)
    {
        cout << "No\n";
    }
    else
    {
        cout << "Yes\n";
        if(n == x)
        {
            for(int i = 1; i <= 2 * n - 1; i++)
                cout << i << ' ';
        }
        else if(x < n)
        {
            for(int i = 2; i <= n; i++)
                if(i != x)
                    cout << i << ' ';
            cout << x << ' ' << 1 << ' ';
            for(int i = n + 1; i <= 2 * n - 1; i++)
                cout << i << ' ';
        }
        else
        {
            for(int i = 1; i < n; i++)
                cout << i << ' ';
            cout << 2 * n - 1 << ' ' << x << ' ' << n << ' ';
            for(int i = n + 1; i < 2 * n - 1; i++)
if(i != x)
                cout << i << ' ';
        }
    }
    return 0;
}



Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define MAX 10000000

int b[110];

int solve(int a[110][110], int n){
	b[0] = 0;
	for(int i = 0;i < n;i++)
		for(int j = 1;j < n;j++)
			if(a[i][j] != -1)b[j] = min(b[j], a[i][j]+b[i]);
	return 0;
}

int main(){
	int a[110][110], n;
	fill((int*)a, (int*)(a+110), -1);
	fill(b, b+110, MAX);
	cin >> n;
	for(int i = 0;i < n;i++){
		int u, k, c, d;
		cin >> u >> k;
		for(int j = 0;j < k;j++){
			cin >> c >> d;
			a[u][c] = d;
		}
	}
	
	
	
	for(int i = 0;i < n;i++)solve(a, n);
	for(int i = 0;i < n;i++){
		cout << i << " " << b[i] << endl;
	}
	
	return 0;
}
/*
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3
*/

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <utility>
#include <stdio.h>

int main( void ) {

	using namespace std;

	while( true ) {

		//入力を受け取る

		int n, w, d, p, s;
		cin >> n >> w >> d;
		if( !( n|w|d ) ) break;

		//listの宣言　int, int = 横, 縦
		list< pair< int, int > > l;
		l.push_back( make_pair( w, d ) );

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

			cin >> p >> s;
			int indx = 0;
			list< pair< int, int > >::iterator it = l.begin();
			
			//インデックスの走査
			for( ;it != l.end(); ++it ) {
				if( indx == p - 1 )
					break;
				indx ++;
			}

			//カット位置の定義
			if( ( 2 * (*it).first + 2 * (*it).second ) > 0 ) {
				s %= ( 2 * (*it).first + 2 * (*it).second );
			}
		

			pair< pair< int, int >, pair< int, int > > p;

			if( s < (*it).first || ( s < (*it).second + (*it).first * 2 && s > (*it).first + (*it).second ) ) {

				if( ( s < (*it).second + (*it).first * 2 && s > (*it).first + (*it).second ) ) {

					s -= (*it).first + (*it).second;

				}

				p = make_pair( make_pair( s, (*it).second ), make_pair( abs( (*it).first - s ), (*it).second ) );

			} else {

				if( s > (*it).first && s < (*it).first + (*it).second ) {

					s -= (*it).first;

				} else {

					s -= (*it).first * 2 + (*it).second;

				}

				p = make_pair( make_pair( (*it).first, abs( (*it).second - s ) ) , make_pair( (*it).first, s ) );

			}

			it = l.erase( it );

			if( p.first.first * p.first.second < p.second.first * p.second.second ) {
				l.push_back(  p.first );
				l.push_back(  p.second );
				
			} else {
				l.push_back(  p.second );
				l.push_back(  p.first );
			}

		}
		vector< int > sq;

		for( list< pair< int, int > >::iterator it = l.begin(); it != l.end(); ++ it ) {

			sq.push_back( (*it).first * (*it).second );

		}

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

		for( int i = 0; i < sq.size(); i++ ) {
			if( i > 0 ) 
				cout << " " << sq[i];
			else
				cout << sq[i];
		}
		cout << endl;
		
		

	}

	return 0;

}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    ll n;
    cin >> n;
    cout << 8 - (n-400)/200 << endl;
    return 0;
}

Measured memory_bytes: 3592
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))

sm=0

for i,y in enumerate(b):
    mn_x=-1
    mx_x=n
    while mx_x-mn_x>=2:
        mid=(mn_x+mx_x)//2
        if a[mid]<y:
            mn_x=mid
        else : mx_x=mid

    mn_z=-1
    mx_z=n
    while mx_z-mn_z>=2:
        mid=(mn_z+mx_z)//2
        if c[mid]>y:
            mx_z=mid
        else : mn_z=mid
    
    sm+=(mn_x+1)*(n-mx_z)

print(sm)

Measured memory_bytes: 29304
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    map<ll, int> mp;

    ll res = 0;

    REP(i, n) {
        cin >> a[i];
        res += mp[i-a[i]];
        mp[i+a[i]]++;
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 26652
import java.util.Scanner;

class Main {
    static public void main(String args[]){

        Scanner scan = new Scanner(System.in);
        int in = scan.nextInt();

        int a,b,c,d;
        d = in % 10;
        in /= 10;
        c = in % 10;
        in /= 10;
        b = in % 10;
        in /= 10;
        a = in % 10;
        in /= 10;

        if(a+b+c+d == 7)
            System.out.println(a+"+"+b+"+"+c+"+"+d+"=7");
        else if(a+b+c-d == 7)
            System.out.println(a+"+"+b+"+"+c+"-"+d+"=7");
        else if(a+b-c+d == 7)
            System.out.println(a+"+"+b+"-"+c+"+"+d+"=7");
        else if(a+b-c-d == 7)
            System.out.println(a+"+"+b+"-"+c+"-"+d+"=7");
        else if(a-b+c+d == 7)
            System.out.println(a+"-"+b+"+"+c+"+"+d+"=7");
        else if(a-b+c-d == 7)
            System.out.println(a+"-"+b+"+"+c+"-"+d+"=7");
        else if(a-b-c+d == 7)
            System.out.println(a+"-"+b+"-"+c+"+"+d+"=7");
        else if(a-b-c-d == 7)
            System.out.println(a+"-"+b+"-"+c+"-"+d+"=7");

    }
}


Measured memory_bytes: 21972
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<cmath>
#define lowbit(x) ((x)&(-x))
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a>b?b:a)
#define INF 0x3f3f3f3f
#define sz size()
#define pb push_back
#define ph push
#define mem(x, y) memset(x, y, sizeof(x));
#define mem0(x) mem(x,0)
#define mem1(x) mem(x,-1)
#define memINF(x) mem(x,INF)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
using namespace std;
typedef long long ll;
int const Max_N = 1e6+5;
ll a[Max_N];
ll sum[Max_N];
int main()
{
 	int N;
	cin >> N;
	rep(i,1,N+1)
	{
		cin >> a[i];
		sum[i] += sum[i-1] + a[i];
	}
	ll ans = 1e18;
	rep(i,1,N)
	{
	//	cout << sum[i] << endl;
	//	cout << sum[N] - 2*sum[i] << endl;
		ans = min(ans,abs(sum[N] - 2*sum[i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5888
n = gets.to_i
kt =[]
kt << gets.chomp
count = 0
(0..n-2).each do |u|
      tk = gets.chomp
       if kt[-1][-1] == tk[0] 
          kt << tk
       if kt.size != kt.uniq.size
           count +=1
           break
       end
    else
        count +=1
       break
    end
end 
puts count == 0 ? "Yes": "No"

Measured memory_bytes: 1916
T_h, T_s, A_h, A_s = map(int, input().split())

# Turns that each need to win
T_t = (A_h + T_s - 1) // T_s # Y
A_t = (T_h + A_s - 1) // A_s # X

if T_t <= A_t:
    print("Yes")
else:
    print("No")


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

using namespace std;

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

    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        string op;
        cin >> op;

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

        if (op == "print") {
            cout << str.substr(a, b - a + 1) << endl;
        } else if (op == "reverse") {
            string t = str.substr(a, b - a + 1);
            int n = t.size();
            for (int i = 0; i < n; i++) str[i + a] = t[n - i - 1];
        } else if (op == "replace") {
            string p;
            cin >> p;
            str = str.replace(a, b - a + 1, p);
        }
    }
}


Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <tuple>
#include <bitset>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define all(c) (c).begin(), (c).end()

const int inf = 1e8;
typedef bitset<110> hasrefrig;

struct Edge {
    int to, wt;
    Edge(int to_, int wt_) : to(to_), wt(wt_) {};
};

typedef vector<Edge> Edges;

struct Graph : vector<Edges> {
    Graph(size_t n) : vector<Edges>(n) {}
    void add(int u, int v, int wt) {
        at(u).emplace_back(v, wt);
        at(v).emplace_back(u, wt);
    }
};

int solve(int M, int A, int H, const hasrefrig& rf, const Graph& G) {
    vector<vector<int>> mem(G.size(), vector<int>(M + 1, inf)); mem[A][M] = 0;
    typedef tuple<int, int, int> State;
    priority_queue<State, vector<State>, greater<State>> Q;
    for (Q.emplace(0, A, M); !Q.empty();) {
        int cost, cur, rerf;
        tie(cost, cur, rerf) = Q.top(); Q.pop();
        if (mem[cur][rerf] < cost) continue;
        for (const auto e: G[cur]) {
            for (int k = rf[cur]? M: rerf; k >= 0; --k) {
                if (k < rerf) break;
                int nxt = cost + e.wt + k - rerf;
                if (k < e.wt || mem[e.to][k - e.wt] <= nxt) continue;
                mem[e.to][k - e.wt] = nxt;
                if (e.to != H) Q.emplace(nxt, e.to, k - e.wt);
            }
        }
    }
    int retval = *min_element(all(mem[H]));
    if (retval == inf) throw "Help!";
    return retval;
}

int main() {
    int N, M, L, K, A, H;
    while (cin >> N >> M >> L >> K >> A >> H, N | M | L | K | A | H) {
        hasrefrig rf; rf.set(A); rf.set(H);
        for (int x; L--; rf.set(x)) cin >> x;
        Graph G(N);
        for (int X, Y, T; K--; G.add(X, Y, T)) cin >> X >> Y >> T;
        try {
            cout << solve(M, A, H, rf, G) << endl;
        }
        catch (char const *mes) {
            cout << mes << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1672
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String u = a.toUpperCase();
		sc.close();
		if (a.equals(u)) {
			System.out.println("A");
		} else {
			System.out.println("a");
		}
	}
}


Measured memory_bytes: 35600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef vector<int> ivec;
typedef vector<string> svec;

//int a[100010];
const double PI=3.14159265358979323846;
int main(){
	double n=0;
	cin>>n;
	
	cout<<PI*n*2<<endl;
} 


Measured memory_bytes: 3788
import copy

N, M=map(int, input().split())
A=list(map(int, input().split()))
BC=[]
for _ in range(M):
    BC.append(tuple(map(int, input().split())))
A=sorted(A)
BC=sorted(BC, key=lambda val:val[1], reverse=True)
#print(N,M,A,BC)


change=[]
for bc in BC:
    for _ in range(bc[0]):
        change.append(bc[1])
    if len(change)>=N:
        break
#print(change)

if A[0]>=change[0]:
    print(sum(A))
else:
    for i in range(min(N,len(change))):
        if A[i]>change[i]:
            answer = sum(change[:i]) + sum(A[i:])
            print(answer)
            break
    else:
        answer=sum(change[:i+1])+sum(A[i+1:])
        print(answer)


Measured memory_bytes: 90604
import sys
if __name__ == "__main__":
    a, b, c, k = map(int, input().split())
    ans = 0

    if k <= a:
        ans = k
        print(ans)
        sys.exit(0)
    else:
        ans = a
        k -= a
    
    if k <= b:
        print(ans)
        sys.exit(0)
    else:
        k -= b

    ans -= k
    print(ans)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; ++i) {
        cin >> h.at(i);
    }
    sort(h.begin(), h.end());

    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        if(h.at(i) >= k) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int	main(void)
{
  	long long		x;
  	double	y;
  	long long		i;
  
  	scanf("%lld", &x);
  
  	y = 100;
  	i = 0;
  	while(y < x)
    {
      	y = floor(y * 1.01);
      	i++;
    }
  	printf("%lld", i);
  	return (0);
}

Measured memory_bytes: 1732
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#define rep(i,j,k) for(register int i = j; i <= k; i++)
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define ll long long
using namespace std;

inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
} 




int main() { 
	ll x = read(), y = read();
	if( x % y != 0 ) printf("%lld\n",x);
	else puts("-1");  
	return 0;
}

Measured memory_bytes: 256
/*
  Lower bound: first element that is greater-or-equal.
  int i=lower_bound(a,a+n,x)-a;
  Upper bound: first element that is strictly greater.
  #include<boost/multiprecision/cpp_int.hpp>
  namespace mp=boost::multiprecision;
  mp::cpp_int u=1; for(unsigned i=1;i<=n;i++) u*=i;
*/
#pragma GCC optimize("O3")  
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
#define I (int)
const int mod=(int)1e9+7;
const long long INF = 1000000000000000000LL;
const int WASTE=(int)2e5;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //#define int long long
   	int n;
   	cin>>n;
   	int a[n];
   	for(int x=0;x<n;x++)
   		cin>>a[x];
   	int ctr=0;
   	while(1){
   		bool f=0;
   		for(int x=0;x<n;x++){
   			if(a[x]%2){
   				f=1;
   				break;
   			}
   			a[x]/=2;
   		}
   		if(f)
   			break;
   		ctr++;
   	}
   	cout<<ctr;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a[1000000]={0};
	a[0]=1;a[1]=1;
	int i,o,b,d,n,sum,p;
	for(i=2;i*i<1000000;i++){
		o=i;
		p=o;
		while(1){
			o+=p;
			if(o>999999)
				break;
			a[o]=1;
		}
	}
	while(1){
		sum=0;
	scanf("%d%d%d",&b,&d,&n);
	if(b==0 && d==0 )
		break;
	while(1){
		if(a[b]==0)
			sum++;
		if(sum==n)
			break;
		b+=d;
	}
	printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 4512
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		String str = sc.next();
		
		StringBuffer st=new StringBuffer(str);
		String str2=st.reverse().toString();
		
		System.out.println(str2);
		
	}

}


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

#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("gymnastics.in","r",stdin );
#define outF freopen("gymnastics.out" , "w" , stdout ) ;
#define sum(a)a * (a + 1 ) / 2
#define ll long long

const double eps = 1e-9 , PI = acos(-1) ;
const int N = 3e3 + 3, oo = 1e17 , M = 1e5 + 5, mod = 1<<30 , K = 12;
string a , b ;
int dp[N][N];

int lcs(int i , int j){
    if(i == a.size() || j == b.size())
        return 0 ;

    int &ret = dp[i][j];
    if(~ret)
        return ret ;
    if(a[i] == b[j])
        ret = lcs(i + 1 , j + 1) + 1;
    else ret = max(lcs(i + 1 , j) , lcs(i , j + 1));

    return ret ;
}

void print(int i , int j){
    if(i == a.size() || j == b.size())
        return ;

    int ret = lcs(i , j);
    if(a[i] == b[j]){
        cout << a[i] ;
        print(i + 1 , j + 1);
        return ;
    }
    if(lcs(i + 1 , j) == ret)
        print(i + 1 , j);
    else print(i , j + 1);


}
int32_t main(){

    //inF;
    // Dont Forget memset
    memset(dp , -1 , sizeof dp);

    //calculate constraints please!!!
    cin >> a >> b ;
    lcs(0 , 0);
    print(0 , 0);
     return 0 ;
}



Measured memory_bytes: 39064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> h(n);
  rep(i,n){
    cin >> h.at(i);
  }
  ll dp[n+1];
  dp[1]=0;
  for(ll i=1;i<n;i++){
    if(i==1){
      dp[2]=abs(h.at(i)-h.at(i-1));
    }else{
      dp[i+1]=min(dp[i]+abs(h.at(i)-h.at(i-1)),dp[i-1]+abs(h.at(i)-h.at(i-2)));
    }
  }
  cout << dp[n];
}


Measured memory_bytes: 4808
/*
 
 * This code is written by Sanskar Agarwal
 
*/
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define VPLL vector<PLL>
#define VPII vector<PII>
#define PQ priority_queue<PLL,VPLL, greater<PLL> > 
#define PQI priority_queue<PII,VPII,greater<PII> >
#define UMLL unordered_map<ll,ll>
#define UMII unordered_map<int,int>
#define VI vector<int>
#define VL vector<ll>
#define S second
#define F first
#define PB push_back

void dfs(ll x,vector<ll> v[],vector<ll> &cst,vector<bool> &vis)
{
    vis[x]=true;
    for(ll i=0;i<v[x].size();i++)
    {
        ll y=v[x][i];
        if(vis[y])
            continue;
        cst[y]+=cst[x];
        dfs(y,v,cst,vis);
    }
}

int main()
{

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

    ll i,n,q;
    cin>>n>>q;
    vector<ll> v[n],cst(n,0);
    vector<bool> vis(n,0);
    for(i=1;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        x--;y--;
        v[x].PB(y);
        v[y].PB(x);
    }
    for(i=0;i<q;i++)
    {
        ll x,ct;
        cin>>x>>ct;
        x--;
        cst[x]+=ct;
    }
    dfs(0,v,cst,vis);
    for(i=0;i<n;i++)
        cout << cst[i] << " ";

    
    return 0;
}

Measured memory_bytes: 30592
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define orta ((bas+son)/2)
#define N 1000005
using namespace std;

int n, bas = 1, son = N, a[N], b[N];
char s[N];

bool dene(int x){
	for(int i = 1; i <= n; i++)
		b[i] = a[i];
	b[1] += 9*x;
	for(int i = 1; i <= n; i++){
		b[i + 1] += b[i]/10;
		b[i] %= 10;
	}
	int top = 0;
	for(int i = 1; i <= n + 2; i++)
		top += b[i];
	return top <= 9*x;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++)
		a[i] = (s[n - i + 1] - '0')*9;
	for(int i = 1; i <= n; i++){
		a[i + 1] += a[i]/10;
		a[i] %= 10;
	}
	if(a[n + 1])
		n++;
	son = n + 5;
	while(bas < son){
		if(dene(orta))
			son = orta;
		else
			bas = orta + 1;
	}
	printf("%d\n", orta);
	return 0;
}

Measured memory_bytes: 7936
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, A = map(int, input().split())
X = list(map(int, input().split()))

dp = [[0] * (N * A + 1) for _ in range(N + 1)]

dp[0][0] = 1

for i in range(0, N):
    for cnt in range(N, 0, -1):
        for val in range(N * A, -1, -1):
            if val - X[i] >= 0:
                dp[cnt][val] += dp[cnt - 1][val - X[i]]

ans = 0
for i in range(1, N + 1):
    ans += dp[i][i * A]

print(ans)

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p)
{
    return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc)
{
    o << "sz = " << vc.size() << endl
      << "[";
    for (const T& v : vc)
        o << v << ",";
    o << "]";
    return o;
}
using ll = long long;
constexpr ll MOD = 1000000007;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A <= C and C <= B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
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 area=a*b;
		double tubo=3.305785;
		
		double ans = area/tubo;
		
		System.out.println(ans);
		

	}
}



Measured memory_bytes: 26500
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<complex>
using namespace std;

#define curr(G, i) G[i%n]
#define next(G, i) G[(i+1)%n]

typedef complex<double> P;

namespace std {
  bool operator < (const P& a, const P& b) {
    return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
  }
}

double cross(const P &a, const P &b){
    return imag(conj(a)*b);
}

double dot(const P &a, const P &b){
    return real(conj(a)*b);
}

int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > 0) return +1;
    if(cross(b,c) < 0) return -1;
    if(dot(b,c) < 0) return +2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

double diameterOfAConvexPolygon(vector<P> &G){
    int n = G.size();

    int k;
    for (k=1;k<n;k++){
       if(norm(G[0] - curr(G, k)) > norm(G[0] - next(G, k))) break;
    }

    int j = 0;
    double res = 0;
    while(j<n+1){
        //cout << j << " " << k << endl;
        //cout << sqrt(norm(curr(G, j)-curr(G, k))) << endl;
        res = max(res, sqrt(norm(curr(G, j)-curr(G, k))));
        P p = next(G, j) - curr(G, j);
        P q = next(G, k) - curr(G, k);
        if (cross(p, q) >= 0){
            k++;
        }else{
            j++;
        }
    }
    return res;
}

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

    vector<P> G;
    for (int i=0;i<n;i++){
        P p;
        cin >> p.real() >> p.imag();
        G.push_back(p);
    }

    printf("%.7f\n", diameterOfAConvexPolygon(G));
}

Measured memory_bytes: 4888
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

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

int x[100], y[100];

int main() {
  int n;
  for (int ii = 1;; ++ii) {
    cin >> n;
    if (n == 0) break;
    double res = 0;
    rep (i, n) cin >> x[i] >> y[i];
    rep (i, n) res += x[i] * y[(i + 1) % n] - y[i] * x[(i + 1) % n];
    printf("%d %.1lf\n", ii, abs(res / 2)); 
  }
}

Measured memory_bytes: 0