akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
 
ll get(ll x) {
    for(int i = 60; i >= 0; i--) {
        if((1LL << i) & x)
            return i;
    }
    return -1;
}
 
int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 
    ll a, b;
    cin >> a >> b;
    if(a == b) {
        cout << "1\n";
        return 0;
    }
    ll pos1 = get(a);
    ll pos2 = get(b);
    ull ans = 0;
    while(pos1 == pos2) {
        a ^= (1LL << pos1);
        b ^= (1LL << pos2);
        pos1 = get(a);
        pos2 = get(b);
    }
    ans += (1LL << pos2) - a + 1;
b ^= (1LL << pos2);
if((1LL << (get(b) + 1)) - 1 < a - 1) {
    ans += ((1LL << (pos1 + 1)) - 1) - a + 1;
    ans += max(0LL, min(a - 1, (1LL << (get(b) + 1)) - 1)); }
else { ans += max((1LL << (pos1 + 1)) - 1, (1LL << (get(b) + 1)) - 1); }
    for(int i = max(get(b) + 1, pos1 + 1); i < pos2; i++) {
        ans += (1LL << i);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        long[] a = sc.LongArray();
        if (a.Contains(0))
        {
            Console.WriteLine("0");
            return;
        }
        long target = 1000000000000000000L;
        long ans = 1;
        for (int i = 0; i < n; i++)
        {
            if (a[i] > target / ans)
            {
                Console.WriteLine("-1");
                return;
            }

            ans *= a[i];
        }
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 41304
class Point
  def initialize(x, y)
    @x = x
    @y = y
  end

  attr_reader :x, :y

  def distance(p)
    (((@x - p.x) ** 2.0 + (@y - p.y) ** 2.0) ** 0.5)
  end
end

a,b,c,d=gets.split.map &:to_f
p1=Point.new(a,b)
p2=Point.new(c,d)
puts p1.distance(p2)



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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

const int N = 2e5+34;

int a[N];
int h[N];

void solve() {
    int n; scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", h+i);
        a[i] = i+1-h[i];
    }
    sort(a, a+n);
    long long ans = 0;
    for (int i = 0; i < n-1; ++i) {
        int x = i+1+h[i];
        const auto p = equal_range(a, a+n, x);
        ans += p.second-p.first;
    }
    printf("%lld", ans);
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5384
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a, b, h, w;
  int m, n;
  cin >> a >> b;
  cin >> h >> w;
  m = a * b;
  n = (b * h) + (a-h)*w;
  cout << m - n << endl;
}


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int D=A;
  string ans="NO";
  for(int i=0; i<B; i++){
    D+=A;
    if(D%B==C) ans="YES";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
const int MAX = 2001;
const int MOD = 1000000007;
 
 


 
signed main(){
    int n;
    cin>>n;
    string s[n],y;
    for(int i=0;i<n;i++)cin>>s[i];
    for(int i=0;i<n;i++)sort(s[i].begin(),s[i].end());
    vector<int> t;
    int u=1;
    priority_queue<string> k;
   for(int i=0;i<n;i++) k.push(s[i]);
    while(!k.empty()){
        y=k.top();
        k.pop();
        if(!k.empty()&&y==k.top()){
            u++;
        }else{
          
            t.push_back(u);
            u=1;
          
        }
    }
    int ans=0;
    for(int i=0;i<t.size();i++){
        ans+=t[i]*(t[i]-1);
     
    }
    cout<<ans/2;


    return 0;
}

Measured memory_bytes: 14324
from itertools import groupby

N,K=map(int,input().split())
S=input()
def condition(num):
    flag=0
    first=[int(S[i]) for i in range(0,N-num+1)]
    last=[int(S[i+num-1]) for i in range(0,N-num+1)]
    test=[]
    for i in range(0,num):
        test.append(int(S[i]))
    sub=groupby(test)
    count=0
    for key,group in sub:
        if key==0:
            count+=1
    if K>=count:
        flag=1
    for i in range(1,N-num+1):
        if first[i-1]==0 and first[i]==1:
            count-=1
        if last[i-1]==1 and last[i]==0:
            count+=1
        if K>=count:
            flag=1
    return flag==1
start=1
end=N
while end-start>1:
    test=(end+start)//2
    if condition(test):
        start=test
    else:
        end=test
if condition(end):
    print(end)
else:
    print(start)


Measured memory_bytes: 104540
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int A = Input.nextInt();
        int B = Input.nextInt();
        int C = Input.nextInt();
        int D = Input.nextInt();

        long CCC = A * B;
        long QQQ = C * D;
        if (QQQ >= CCC) {
            System.out.println(QQQ);
        } else {
            System.out.println(CCC);
        }

    }
}


Measured memory_bytes: 23124
#include <stdio.h>

void matrixChainOrder(void);
int num,p[101],m[101][101];
int main(){
  int i,a;
  scanf("%d",&num);
  for(i=0;i<num-1;i++)scanf("%d%d",&p[i],&a);
  scanf("%d%d",&p[num-1],&p[num]);
  matrixChainOrder();
  printf("%d\n",m[1][num]);
  return 0;
}
void matrixChainOrder(void){
  int i,n,l,j,k,q;
  n =num;
  for (i = 1; i<=n;i++)
    m[i][i] = 0;
  for (l = 2;l<=n;l++)
    for (i = 1;i<n-l+2;i++){
      j = i+l-1;
      m[i][j] = 1000000;
      for (k = i;k<j;k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	  
	if(m[i][j]>q)m[i][j] =  q;
      }
    }

}

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

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

  int flag=0;
  for(int i=0; i<s.size(); i++){
    if(s[i]=='+') flag++;
    if(s[i]=='-') flag--;
  }
  cout << flag << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>


using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const long long int INF=1001001001001001001;
int N,K;
long long int T[1002];long long int A[1002];

int main(){
	scanf("%d",&N);
	long long int ans=0;
	long long int gt=1,ga=1;
	rep(i,N){
		scanf("%d %d",&T[i],&A[i]);
		long long int k=1;//
		k=max((long long int)( (gt/T[i])+(bool)(gt%T[i]) ), (long long int)( (ga/A[i])+(bool)(ga%A[i])) );
		gt=T[i]*k;ga=A[i]*k;
	}
	printf("%lld\n",gt+ga);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int isprime[100001];
int isprime_num[100001];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  REP(i,100001) isprime[i] = 1;
  isprime[1] = 0;
  for(int i=2; i<100000; i++){
    if(isprime[i]){
      for(int j=2; i*j<100000; j++) isprime[j*i] = 0;
    }
    if(isprime[i] && isprime[(i+1)/2]){
      isprime_num[i] = 1;
      //cout << "L " << i << '\n';
    }
  }
  FOR(i,1,100000) isprime_num[i+1] += isprime_num[i];
  int Q;
  cin >> Q;
  REP(q,Q){
    int l,r;
    cin >> l >> r;
    cout << isprime_num[r] - isprime_num[l-1]<< '\n';
  }
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
const int maxn=2e6+10;
const int mod=1e9+7;
long long fac[maxn], inv[maxn];
long long qp(long long a, long long b) {
    long long res=1;
    while (b)
	{
        if (b&1)
			res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
long long C(long long n, long long m)
{
   	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	int k,i,j;
	string s;
    fac[0]=1;
    for(i=1;i<maxn;i++)
        fac[i]=fac[i-1]*i%mod;
    inv[maxn-1]=qp(fac[maxn-1],mod-2);
    for(i=maxn-2;i>=0;i--)
        inv[i]=inv[i+1]*(i+1)%mod;
	cin>>k>>s;
    int n=k+s.size();
    long long ans=0;
    for (int i=s.size();i<=n;i++)
        ans+=C(n,i)*qp(25,n-i)%mod,ans%=mod;
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
  int n, a, b, c, d;
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
  b -= a;
  for (int i = 0; i < n; i++) {
    long long low = -1ll * d * i + 1ll * c * (n - 1 - i);
    long long high = -1ll * c * i + 1ll * d * (n - 1 - i);
    if (low <= b && b <= high) {
      cerr << i << ' ' << low << ' ' << b << ' ' << high << endl;
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
		int[] q = IntStream.range(0, n).map(i -> sc.nextInt()).toArray();
		sc.close();

		List<List<Integer>> list = new ArrayList<List<Integer>>();
		create(n, new ArrayList<Integer>(), list);
		int pi = getIndex(list, p);
		int qi = getIndex(list, q);
		System.out.println(Math.abs(pi - qi));
	}

	public static void create(int n, List<Integer> numbers, List<List<Integer>> list) {
		if (numbers.size() == n) {
			list.add(numbers);
		}

		for (int i = 1; i <= n; i++) {
			if (!numbers.contains(i)) {
				List<Integer> newNumbers = new ArrayList<Integer>(numbers);
				newNumbers.add(i);
				create(n, newNumbers, list);
			}
		}
	}

	public static int getIndex(List<List<Integer>> list, int[] p) {
		for (int i = 0; i < list.size(); i++) {
			boolean check = true;
			for (int j = 0; j < list.get(i).size(); j++) {
				if (list.get(i).get(j) != p[j]) {
					check = false;
					break;
				}
			}
			if (check) {
				return i;
			}
		}

		return -1;
	}
}


Measured memory_bytes: 44008
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}


using namespace std;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(int argc, char *argv[]) {
    ll result = 0;
    ll a;
    string s;
    cin >> a >> s;
    
    if(a >= 3200){
        cout << s << endl;
    }else {
        cout << "red" << endl;
    }
    return 0;
}


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

typedef long long ll;

using namespace std;

ll x[500005];

int main(){
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  sort(x, x + n);
  for(ll i=0;i<k;i++){
    ans += x[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;

#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 2*10E3+7;
const ll INF = 10E17;

int main()
{

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

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll n1 = c/b+(c%b!=0);
    ll n2 = a/d+(a%d!=0);
    if (n1<=n2)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

  void swap(int *x, int *y);


int main(void){
  int X,Y,Z;
  
  scanf("%d %d %d", &X, &Y, &Z);
  swap(&X, &Y);
  swap(&X, &Z);

   printf("%d %d %d", X, Y, Z);

  return 0;

}


void swap(int *x, int *y){
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
  return 0;
}



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

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll

const int md = 1000000007;
const int INF = 1<<30;

int main(){
    vector<vector<int>> a(3,vector<int>(3,0));

    rep(i,3) cin >> a[i];

    int n; cin >> n;

    vi b(n);
    cin >> b;

    bool bo[3][3];

    rep(i,3){
        rep(j,3){
            bool f = false;
            rep(k,n){
                if(b[k] == a[i][j]) f = true;
            }
            bo[i][j] = f;
        }
    }
    //rep(i,3) rep(j,3) cout << bo[i][j] << ( j < 2 ? ' ' : '\n');

    bool ans = false;

    rep(i,3){
        if(bo[i][0] and bo[i][1] and bo[i][2]) {
            ans = true;
            //cout << i << endl;
        }
        if(bo[0][i] and bo[1][i] and bo[2][i]) {
            ans = true;
            //cout << i << endl;
        }
    }

    if(bo[0][0] and bo[1][1] and bo[2][2]) ans = true;
    if(bo[2][0] and bo[1][1] and bo[0][2]) ans = true;

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    int d[50] = {0};
    for(int i=0; i<N; i++){
        scanf("%d", &d[i]);
    }
    //int num = 0;
    //num = N*(N-1)/2;
    int o[2500] = {0};
    int count = 0;
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            //o[count] = d[i] * d[j];
            //count++;
            count += d[i] * d[j];
        }
    }
    printf("%d\n", count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

vector<vector<int>> edge;
pair<int,int> bfs(int a,int N) {
	int id = 0, md = 0;
	queue<int> qu;
	qu.push(a);
	vector<bool> vi(N + 1);
	vi[a] = true;
	vector<int> dis(N + 1);
	while (!qu.empty()) {
		int x = qu.front();
		qu.pop();
		//cout << "x=" << x << endl;
		for (auto to : edge[x]) {
			if (vi[to])continue;
			vi[to] = true;
			dis[to] = dis[x] + 1;
			qu.push(to);
			if (md < dis[to]) {
				md = dis[to];
				id = to;
			}
		}

	}

	return make_pair(id, md);
}

int main() {
	int N; cin >> N;
	edge=vector<vector<int>>(N + 1);
	for (int i = 0; i < N - 1; i++) {
		int a, b; cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	int id = bfs(1, N).first;
	pair<int,int> L = bfs(id, N);
	//cout << "id=" << id << " L=" << L.second <<"to="<< L.first<<endl;
	if ((L.second + 1) % 3 == 2) cout << "Second" << endl;
	else cout << "First" << endl;
}




Measured memory_bytes: 16520
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		if(r<1200){
			System.out.println("ABC");
		}else if(r<2800){
			System.out.println("ARC");
		}else{
			System.out.println("AGC");
		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
using namespace std;
int main() 
{
	int sx,sy,tx,ty,ssx,ssy,ttx,tty;
	while(~scanf("%d%d%d%d",&sx,&sy,&tx,&ty))
	{
		ssx=sx;
		ssy=sy;
		//ttx=tx;
		//tty=ty;
		while(ssy<ty)
		{
			ssy++;
			cout<<'U';
		}
		while(ssx<tx)
		{
			ssx++;
			cout<<'R';
		}
		while(ssy>sy)
		{
			ssy--;
			cout<<'D';
		}
		while(ssx>sx)
		{
			ssx--;
			cout<<'L';
		}
		
		ssx--;
		cout<<'L';
		while(ssy<ty+1)
		{
			ssy++;
			cout<<'U';
		}
		while(ssx<tx)
		{
			ssx++;
			cout<<'R';
		}
		ssy--;
		cout<<'D';
		ssx++;
		cout<<'R';
		while(ssy>sy-1)
		{
			ssy--;
			cout<<'D';
		}
		while(ssx>sx)
		{
			ssx--;
			cout<<'L';
		}
		cout<<'U'<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x) 			memset(x, 0, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;

	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int a[10];
		rep(i,1,5)
		{
			cin >> a[i];
		}
		rep(i,1,5)
		{
			if(a[i]==0)
			{
				cout << i;
				return 0;
			}
		}
	}
}



Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long k,a,b,i=0;
    cin>>k>>a>>b;
    if(a<=b&&k>a) {
        cout<<-1<<'\n';
        return 0;
    }
    if(k<=a) {
        cout<<1;
        return 0;
    }
    i+=(k-a)/(a-b)*2;
    if((k-a)%(a-b)==0) {
    	cout<<i+1<<'\n';
	} else {
		cout<<i+3<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    vector<int> mae(N-1), ushiro(N-1), dif(N-1);
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> W[i];
        sum += W[i];
    }

    mae[0] = W[0]; ushiro[0] = sum;
    dif[0] = abs(mae[0] - ushiro[0]);
    for(int i = 1; i < N-1; i++){
        mae[i] = W[i] + mae[i-1];
        ushiro[i] = sum - mae[i];
        dif[i] = abs(mae[i] - ushiro[i]);
    }

    cout << *min_element(dif.begin(), dif.end()) << endl;

}
 

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

// dp[i][j][k]:i,j,kから全ての寿司がなくなるまでの期待値
double dp[333][333][333];
int N, cnt[3];

double solve(int A,int B,int C){
  if(dp[A][B][C]>=0) return dp[A][B][C];
  if(A+B+C==0) return (dp[0][0][0]=0);
  double res=0;
  // 寿司ありの皿をとるまでの期待値
  double add=1.0/(A+B+C)*N;
  if(A) res+=(solve(A-1,B+1,C)+add)*A/(A+B+C);
  if(B) res+=(solve(A,B-1,C+1)+add)*B/(A+B+C);
  if(C) res+=(solve(A,B,C-1)+add)*C/(A+B+C);
  return (dp[A][B][C]=res);
}

int main(){
  cin>>N;
  rep(i,N){
    int a; cin>>a;
    cnt[a-1]++;
  }
  rep(i,333) rep(j,333) rep(k,333) dp[i][j][k]=-1;
  cout<<setprecision(15);
  cout<<solve(cnt[2],cnt[1],cnt[0])<<endl;
  return 0;
}


Measured memory_bytes: 288768
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define mod (1e9 + 7)
#define pb push_back
#define ll long long int
using namespace std;
typedef pair<int,int> pii;

int main(){
  int n,k;
  vector<int> a(2*n);
  cin>>k>>n;
  for(int i=0;i<n;i++) cin>>a[i];

  for(int i=n;i<n*2;i++){
    a[i]=k+a[i-n];
  }
  int res=k;
  for(int i=0;i<n;i++){
    res=min(res, a[n-1+i] - a[i]);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 33024
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != ','){
            cout << s[i];
        }
        else
        {
            cout << " ";
        }
        
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
string s1,s2;
int main(){
	scanf("%d",&n);
	cin >> s1 >> s2;
	for(int i=0;i<n;i++){
		if(s1.substr(i,n-i)==s2.substr(0,n-i)){
			cnt=n-i;
			break;
		}
	}
	cout << 2*n-cnt;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var X = cin.ReadLong;
            var flag = false;
            double a = 0;

            while (true)
            {
                if (X % 2 != 0)
                {
                    for (long i = 3; i <= X / 2; i = i + 2)
                    {
                        if (X % i == 0)
                        {
                            break;
                        }
                        if (i + 2 > X / 2)
                        {
                            a = X;
                            flag = true;
                            break;
                        }
                    }
                }
                else if (X == 2)
                {
                    flag = true;
                    a = X;
                    break;
                }
                if (flag ==  true)
                {
                    break;
                }
                X++;
            }

            WriteLine(X);


        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

int main() {
    vector<int> a(3);
    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int target = a[2];
    int k;
    cin >> k;
    int sum = a[0] + a[1] + a[2] * pow(2,k);
    cout << sum;
}

Measured memory_bytes: 256
N = int(input())
arr = list(map(int,input().split()))
num = 1
for i in range(N-1):
  if num == arr[i]:
    num += 1
    
if N>1:
  if num==1 and arr[-1]!=1:
    print(-1)
  elif num==1 and arr[-1]==1:
    print(1)
  elif num!=1 and arr[-1]==num:
    print(N-num)
  elif num!=1 and arr[-1]!=num:
    print(N-num+1)

else:
  if arr[0]==1:
    print(0)
  else:
    print(-1)
  

  

Measured memory_bytes: 26140
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int A,B;

int main(){
    cin>>A>>B;
    out((A+B)%24);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef struct{
	string name;
	int L,P,A,B,C,D,E,F,S,M;
	int time;
	int shu;
	double kou;
}CROP;
int main(){
	for(int n;cin>>n,n;cout<<"#"<<endl){
		CROP crop[50];
		for(int i=0;i<n;i++){
			cin>>crop[i].name;
			cin>>crop[i].P;
			cin>>crop[i].A;
			cin>>crop[i].B;
			cin>>crop[i].C;
			cin>>crop[i].D;
			cin>>crop[i].E;
			cin>>crop[i].F;
			cin>>crop[i].S;
			cin>>crop[i].M;
			crop[i].time=crop[i].A+crop[i].B+crop[i].C+(crop[i].D+crop[i].E)*crop[i].M;
			crop[i].shu=crop[i].F*crop[i].S*crop[i].M-crop[i].P;
			crop[i].kou=(double)crop[i].shu/crop[i].time;
		}
		for(int i=0;i<=n*2;i++){
			for(int j=0;j+1<n;j++){
				if(crop[j].kou==crop[j+1].kou){
					if(crop[j].name>crop[j+1].name){
						swap(crop[j].kou,crop[j+1].kou);
						swap(crop[j].name,crop[j+1].name);
					}
				}
				else if(crop[j].kou<crop[j+1].kou){
					swap(crop[j].kou,crop[j+1].kou);
					swap(crop[j].name,crop[j+1].name);
				}
			}
		}
		for(int i=0;i<n;i++)cout<<crop[i].name<<endl;
	}
	return 0;
}


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

int main() {
  int x,y;
  cin >> x >> y;
  int a=30;
  int b=50;
  int c=70;
  
  if (x == 4 || x == 6 || x == 9 || x == 11) {
     x = a;
  }
  else if(x == 2) {
  x = b;
  }
  else {
  x = c;
  }
  if (y == 4 || y == 6 || y == 9 || y == 11) {
     y = a;
  }
  else if(y == 2) {
  y = b;
  }
  else {
  y = c;
  }

  if (x == y) {
  cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
for i in range(int(input())):
    p1 = p2 = p3 = out = cnt = 0
    while True:
        s = input()
        if s =="HIT":
            if p3 > 0:
                cnt += 1
            p3, p2, p1 = p2, p1, 1
        elif s == "HOMERUN":
            cnt += p1 + p2 + p3 +1
            p1 = p2 = p3 = 0
        else:
            out += 1
            if out == 3:
                break
    print(cnt)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    if( 0<a ) cout << "Positive" << endl;
    else if( a<=0 && 0<=b ) cout << "Zero" << endl;
    else if( (b-a)%2 == 0 ) cout << "Negative" << endl;
    else cout << "Positive" << endl;
}

Measured memory_bytes: 256
x, y = [int(i) for i in input().split()]
temp = y - (2*x)
if (temp % 2 != 0) or (temp < 0):
    print("No")
else:
    t1 = x - (temp//2)
    if t1 < 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 61648
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val S = sc.next

    var ans = 0
    for (i <- 0 until S.length / 2) {
      if (S(i) != S(S.length - i - 1)) {
        ans += 1
      }
    }
    ans.toString
  }
}


Measured memory_bytes: 25548
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;


int main()
{
	double a, b;
	int  h, m;
	cin >> a >> b >> h >> m;
	int rada = 6 * m;
	double radb = (60.0 * h + m) / 2.0;

	double rad = radb - rada > 180 ? 360 - radb + rada : radb - rada;
	rad = rad * PI / 180;
	//printf(" %f %f", rad, cos(rad));
	double c2 = (double)a * a + (double)b * b - 2.0 * a * b * cos(rad);

	printf("%.12f", sqrt(c2));

}



Measured memory_bytes: 4216
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;

const int N_MAX = 12;
const int S_MAX = 1 << N_MAX;
const int M_MAX = 1000;
const int INF = 100000005;

int dp[M_MAX + 5][S_MAX + 5];

int main(){
    int n, m;
    cin >> n >> m;
    int a[M_MAX+3], b[M_MAX+3];
    int c[M_MAX+3][N_MAX+3];
    int Sc[M_MAX+3];
    memset(Sc, 0, sizeof(Sc));
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        for(int j = 0; j < b[i]; j++){
            cin >> c[i][j];
            c[i][j]--;
            Sc[i] |= (1 << c[i][j]);
        }
    }

    for(int i = 0; i <= m; i++){
        for(int S = 0; S != 1 << n; S++)dp[i][S] = INF;
    }

    dp[0][0] = 0;
    for(int i = 0; i < m; i++){
        for(int S = 0; S != 1 << n; S++){
            dp[i+1][S] = min(dp[i+1][S], dp[i][S]);
            dp[i+1][S|Sc[i]] = min(dp[i+1][S|Sc[i]], dp[i][S]+a[i]);
        }
    }
    int ans;
    if (dp[m][(1 << n)-1] < INF)ans = dp[m][(1 << n)-1];
    else ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19272
#include <iostream>

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

	int won = 0, wonB = 0;
	for (int i = 0; i < n; ++i) {
		char c;
		std::cin >> c;

		if (c == 'a') {
			if (won < a + b) {
				++won;

				std::cout << "Yes" << std::endl;
				continue;
			}
		}
		else if (c == 'b') {
			if (won < a + b && wonB < b) {
				++won;
				++wonB;

				std::cout << "Yes" << std::endl;
				continue;
			}
		}

		std::cout << "No" << std::endl;
	}
}

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

string S, T;

int main(){
    cin >> S >> T;
    if(S.size() <= 10){
        if(T.erase(S.size()) == S ) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n;
  cin>>n;
  vi S(n),C(n),F(n);
  rep(i,n-1){
    cin>>C[i]>>S[i]>>F[i];
  }
  rep(i,n-1){
    int t=0;
    FOR(j,i,n-2){
      chmax(t,S[j]); //t>=S[j]
      while(t%F[j]>0){
        t++;
      }
      t+=C[j];
    }
    cout<<t<<endl;
  }
  cout<<0<<endl;

  return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 10000; i++) {
        int ta = i * 8;
        ta /= 100;
        int tb = i / 10;
        if (ta == a && tb == b) {
            cout << i << '\n';
            exit(0);
        }
    }
    cout << -1 << '\n';
    return 0;
}

Measured memory_bytes: 256
// /* Dsingh_24 */

// #include<bits/stdc++.h>
// #define ll          long long
// #define pb          push_back
// #define	endl		'\n'
// #define pii         pair<ll int,ll int>
// #define vi          vector<ll int>
// #define all(a)      (a).begin(),(a).end()
// #define F           first
// #define S           second
// #define sz(x)       (ll int)x.size()
// #define hell        1000000007
// #define rep(i,a,b)	for(ll int i=a;i<b;i++)
// #define lbnd        lower_bound
// #define ubnd        upper_bound
// #define bs          binary_search
// #define mp          make_pair
// #define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// using namespace std;

// #define N  100005
// ll a[N],b[N],c[N],x,y,z,k;
// ll check(ll m){
// 	ll i,j,tot=0;
// 	for(i=0;i<x;i++){
// 		for(j=0;j<y;j++){
// 			if(a[i]+b[j]>m)break;
// 			ll cc=m-(a[i]+b[j]);
// 			ll cnt=lbnd(c,c+z,cc)-c;
// 			if(c[cnt]==cc)cnt++;
// 			tot+=cnt;
// 		}
// 	}
// 	return (tot>=k);
// }
// int main()
// {
// 	ios
// 	ll x,y,z,k,i,j,ans=0;
// 	cin>>x>>y>>z>>k;
	
// 	for(i=0;i<x;i++)
// 		cin>>a[i];
// 	for(i=0;i<y;i++)
// 		cin>>b[i];
// 	for(i=0;i<z;i++)
// 		cin>>c[i];
// 	sort(a,a+x);
// 	sort(b,b+y);
// 	sort(c,c+z);
// 	ll lo=0,hi=3*1e10,mid;
// 	while(hi-lo>1){
// 		mid=(hi+lo)/2;
// 		if(check(mid))
// 			hi=mid;
// 		else
// 			lo=mid;
// 		cout<<mid<<"\n";
// 	}
// 	if(check(lo))ans=lo;else ans=hi;
// 	cout<<ans;
// 	return 0;
// }
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
ll x,y,z,a[N],b[N],c[N],n;
priority_queue<pair<ll,pair<ll,pii> > >q;
map<pair<ll,pii>,ll>vis;
int main()
{
	ios
	cin>>x>>y>>z>>n;
	ll i,j,k;
	for(i=0;i<x;i++)
		cin>>a[i];
	for(i=0;i<y;i++)
		cin>>b[i];
	for(i=0;i<z;i++)
		cin>>c[i];
	sort(a,a+x);
	reverse(a,a+x);
	sort(b,b+y);
	reverse(b,b+y);
	sort(c,c+z);
	reverse(c,c+z);
	q.push(mp(a[0]+b[0]+c[0],mp(0,mp(0,0))));
	vis[mp(0,mp(0,0))]=1;
	vi ans;
	while(n>0){
		auto ii=q.top();
		q.pop();
		i=ii.S.F,j=ii.S.S.F,k=ii.S.S.S;
		if(vis[mp(i,mp(j,k+1))]==0&&k+1<z){
			vis[mp(i,mp(j,k+1))]=1;
			q.push(mp(a[i]+b[j]+c[k+1],mp(i,mp(j,k+1))));
		}
		if(vis[mp(i,mp(j+1,k))]==0&&j+1<y){
			vis[mp(i,mp(j+1,k))]=1;
			q.push(mp(a[i]+b[j+1]+c[k],mp(i,mp(j+1,k))));
		}
		if(vis[mp(i+1,mp(j,k))]==0&&i+1<x){
			vis[mp(i+1,mp(j,k))]=1;
			q.push(mp(a[i+1]+b[j]+c[k],mp(i+1,mp(j,k))));
		}
		ans.pb(ii.F);
		n--;
	}
	for(auto i:ans)cout<<i<<"\n";
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
string x,y;
int LCS[1002][1002];


int searchLCS(int now_x, int now_y){
    // cout << now_x << " : " << now_y << endl;
    if(LCS[now_x+1][now_y+1] > 0) return LCS[now_x+1][now_y+1];
    if(now_x < 0 || now_y < 0) return LCS[now_x+1][now_y+1] = 0;
    if(x[now_x] == y[now_y]){
        return LCS[now_x+1][now_y+1] = searchLCS(now_x-1,now_y-1)+1;
    }else if(now_x >= 0 && now_y >= 0){
        return LCS[now_x+1][now_y+1] = max(searchLCS(now_x-1,now_y),searchLCS(now_x,now_y-1));
    }
    return 0;
}

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i < n;i++){
        cin >> x;
        cin >> y;
        for(int i = 0; i < x.length()+1;i++){
            for(int l = 0; l < x.length()+1;l++){
                LCS[i][l] = -1;
            }
        }
        cout << searchLCS(x.length()-1,y.length()-1) << endl;
    }
    

    return 0;
}


Measured memory_bytes: 7236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  char s;
  cin>>s;
  if (isupper(s)) cout << "A" << endl;
  else
    cout << "a" << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main(void)
{
  vector<int> prime = {2};
  for(int i = 3; i != 1000; i++){
    for(int j : prime){
      if(i % j == 0) break;
      if(j * j > i){
        prime.push_back(i);
        break;
      }
    }
  }
  int n; cin >> n;
  long long ans = 1;
  for(int j : prime){
    int t = n, x = 0;
    while(t){
      t /= j;
      x += t;
    }
    ans = (ans * (long long)(x + 1)) % MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  using P = pair<Double, Double>;

  Int N;
  cin>>N;
  vector<P> A(N);
  cin>>A;

  sort(A.begin(), A.end(), [&](P a, P b){
      Double p = atan2(a.second, a.first);
      Double q = atan2(b.second, b.first);
      return p < q;
    });

  Int ans = 0;
  for(Int i=0;i<N;i++)
    for(Int j=0;j<N;j++){
      Int idx = i;
      Int x = 0, y = 0;
      while(1){
        x += A[idx].first;
        y += A[idx].second;
        Max(ans, x * x + y * y);
        if(idx == j) break;
        idx = (idx + 1)%N;
      }
    }

  cout<<sqrt((Double)ans)<<endl;

  return 0;
}


Measured memory_bytes: 256
/* **********************************JAI SAI RAM ************************************* */
//HELP IN CODEFORCES ROUND 641
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);   
    ll i,j,k,l,m,n,o,p,x,y;
    ll v[10000];
    set<ll> se;
    for(i=-10;i<=10000;i++)
    {
        se.insert(i);
    }
    cin>>x>>n;
    for(i=0;i<n;i++)
    {
        cin>>v[i];
        se.erase(v[i]);
    }
    sort(v,v+n);
    m=LLONG_MAX;
    ll ans=v[0];
    for(auto it:se)
    {
        if(m>abs(x-it))
        {
            m=abs(x-it);
            ans=it;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4112
def postorder(pre,inor):
    if len(pre) <= 1:
        return pre
    else:
        root = pre[0]
        i = inor.index(root)
        leftin = inor[:i]
        leftpre = pre[1:i+1]
        rightin = inor[i+1:]
        rightpre = pre[i+1:]
        left = postorder(leftpre,leftin)
        right = postorder(rightpre,rightin)
        return left+right+[root]
n = str(input())
pre = list(map(str,input().split()))
inor = list(map(str,input().split()))
print(" ".join(postorder(pre,inor)))


Measured memory_bytes: 5572
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int table[100001];
    int i;
    for(i=0;i<100001;i++){
        table[i]=0;
    }
    int n, q;
    cin >> n;
    int a[n];
    long long sum=0;
    for(i=0;i<n;i++){
        cin >> a[i];
        table[a[i]] ++;
        sum+=a[i];
    }
    cin >> q;
    int b,c;
    for(i=0;i<q;i++){
        cin >> b >> c;
        sum += (c-b)*table[b];
        table[c]+=table[b];
        table[b]=0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 4420
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


NUM = 10
POW = [1]*(NUM+1)
for i in range(1,NUM+1):
    POW[i] = POW[i-1]*2


N = int(input())

for _ in range(N):

    table = list(map(int,input().split()))

    FLG = False

    for state in range(POW[NUM]):
        A = []
        B = []

        for i in range(NUM):
            if state & POW[i] != 0:
                A.append(table[i])
            else:
                B.append(table[i])

        tmpFLG = True
        for i in range(len(A)-1):
            if A[i] >= A[i+1]:
                tmpFLG = False
                break

        if tmpFLG == False:
            continue

        for i in range(len(B)-1):
            if B[i] >= B[i+1]:
                tmpFLG = False
                break

        if tmpFLG == True:
            FLG = True
            break


    if FLG == True:
        print("YES")
    else:
        print("NO")



Measured memory_bytes: 13760
#include <stdio.h>


int main(){
	
	int n,k,x[101],i,sum=0;
	
	scanf("%d %d",&n,&k);
	
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
		if(x[i]<=abs(k-x[i]))sum=sum+x[i];
		else sum=sum+abs(k-x[i]);
	}
	
	printf("%d\n",sum*2);
	
	return 0;
}


Measured memory_bytes: 128