akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static int[] N;

    static void INPUT()
    {
        N = LineInt();
    }
    static void OUT()
    {
        var t = N[1] / 1000;
        for (var x = 0; x <= N[0]; x++)
            for (var v = 0; v <= N[0] - x; v++)
            {
                var o = N[0] - x - v;
                if (10 * x + 5 * v + o== t)
                {
                    Console.WriteLine(string.Format("{0} {1} {2}", x, v, o));
                    return;
                }
            }
        Console.WriteLine(string.Format("{0} {1} {2}", -1, -1, -1));
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
        //INPUT();
#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
        N = new int[] { 9, 45000 };
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
int main()
{
    while(1)
    {
        int N, X;
        cin >> N >> X;
        if(N == 0 && X == 0){ break; }
        int ans = 0;
        for(int i = 1; i <= N; ++i)
        {
            for(int j = i + 1; j <= N; ++j)
            {
                for(int k = j + 1; k <= N; ++k)
                {
                    if(i + j + k == X)
                    {
                        ++ans;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ft fflush(stdout)
 
 
using namespace std;
 
 
const int N = 3e5 + 123;
const int PLS = 3e5 + 123;
const ll mod = 1e9 + 7;
const ll inf = 1e16;


ll n, m, dp[3010][3010];
char a[3010][3010];


int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            if (i == 1 && j == 1)
                continue;
            if (a[i][j] == '#')
                continue;
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    cout << dp[n][m];
}


Measured memory_bytes: 28928
N = int(input())
mod = 10 ** 9 + 7 
f = 1
res = 1
for i in range(2, N + 1): f *= i
for i in range(2, N + 1):
  c = 0
  while f % i == 0:
    c += 1
    f //= i
  res *= (c + 1) % mod
  res %= mod
print(res % mod)

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

using namespace std;

int main(void) {

  int X;
  int Y;
  cin >> X >> Y;
  for (int a = 0; a <= X; a++) {
    for (int b = 0; b <= X; b++) {
      if ( a + b == X && 2 * a + 4 * b == Y) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl; 

}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>

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

typedef long long ll;

using namespace std;

int main() {

    string s;
    cin >> s;

    int k;
    cin >> k;

    int n = s.size();

    vector<string> vec;
    FOR(j, 1, min(n,5)+1){
        FOR(i, 0, n-j+1){
            vec.push_back(s.substr(i,j));
        }
    }

    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());

    cout << vec[k-1] << endl;

    //return 0;
}

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

int	main()
{
	int x;
	for (int i = 0; i < 5; ++i) {
		cin >> x;
		if (x == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll e=c*d/__gcd(c,d);
	ll ans=(b-(b/c)-(b/d)+(b/e))-(a-1-((a-1)/c)-((a-1)/d)+((a-1)/e));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import collections

n=int(input())
l=list(map(int,input().split()))

ans=0
ll=[0]*(n+1)
for i in l:
    ans-=int(ll[i]*(ll[i]-1)/2)
    ll[i]+=1
    ans+=int(ll[i]*(ll[i]-1)/2)
#print(ll)
for j in l:
    b=int(ll[j]*(ll[j]-1)/2)
    c=int((ll[j]-1)*(ll[j]-2)/2)
    print(ans-b+c)

Measured memory_bytes: 84172
#include<stdio.h>
#include<stdlib.h>

int compare(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){
  char str[50][100] = {};
  int strnum[50] = {};
  int minletnum[26] = {};
  int letnum[26] = {};
  int n = 0;
  int i= 0;
  int j = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %s",str[i]);
  }
  
  for(i=0;i<26;i++){
    minletnum[i] = -1;
  }
  
  for(i=0;i<n;i++){
    for(j=0;;j++){
      if(str[i][j] != '\0'){
        strnum[i]++;
      }else{
        break;
      }
    }
  }
  /*for(i=0;i<n;i++){
    printf("%d\n",strnum[i]);
  }*/
  
  /*for(i=0;i<n;i++){
    qsort(str[i],strnum[i],sizeof(char),compare);
    printf("%s\n",str[i]);
  }*/
  
  for(i=0;i<n;i++){
    for(j=0;j<26;j++){
      letnum[j] = 0;
    }
    for(j=0;j<strnum[i];j++){
      letnum[str[i][j] - 'a']++;
      //printf("%c,%d#",str[i][j],letnum[str[i][j] - 'a']);
    }
    for(j=0;j<26;j++){
      if(minletnum[j] > letnum[j] || minletnum[j] == -1){
        minletnum[j] = letnum[j];
      }
    }
  }
  
  for(i=0;i<26;i++){
    for(j=0;j<minletnum[i];j++){
      printf("%c",i+'a');
    }
  } 
  return 0;
}
  

Measured memory_bytes: 128
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int a = int.Parse(In[0]);
            int b = int.Parse(In[1]);
            int c = int.Parse(In[2]);
            if((a<=c && c<=b )|| (b <= c && c <= a))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27536
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, M;
    cin >> N >> M;
    vector<vector<ll>> job(1e5+1);
    // for (auto e : job) {
    //     e.push_back(0);
    // }
    Rep (i, N) {
        ll a, b;
        cin >> a >> b;
        job.at(a).push_back(b);
    }

    ll ans = 0;
    priority_queue<ll> choice;
    for (ll i = 1; i <= M; i++) {
        for (auto e : job.at(i)) {
            choice.push(e);
        }
        if (!choice.empty()){
            ll a = choice.top();
            choice.pop();
            ans += a;
        }
    }

    cout << ans << "\n";

}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

int dp[105][4][2];
// dp[i][j][k] i digit(s), j non-zero digit(s), k = 0 ok, k = 1 not yet

int main()
{
    IOS;
    string s;
    int n, K;
    cin >> s >> K;
    n = (int)s.size();
    dp[0][0][0] = 1;
    FOR(i, 0, n) FOR(j, 0, 4) FOR(k, 0, 2)
    {
        int nd = (s[i] - '0');
        FOR(d, 0, 10)
        {
            int ni = i + 1, nj = j, nk = k;
            if (d != 0)
            {
                ++nj;
            }
            if (nj > K)
            {
                continue;
            }
            if(k == 0)
            {
                if(d > nd)
                {
                    continue;
                }
                if(d < nd)
                {
                    nk = 1;
                }
            }
            dp[ni][nj][nk] += dp[i][j][k];
            // cout << ni << ' ' << nj << ' ' << nk << ' ' << dp[ni][nj][nk] << '\n';
        }
    }
    int ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << '\n';
}


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

using namespace std;

int main()
{
    int N,cnt=0,m=0;
    vector <int> entered;
    vector <int> required;
    cin >>N;
    for(int i=0;i<N;i++){
        cin>>m;
        entered.push_back(m);
    }
    for(int i=1;i<N+1;i++){
        required.push_back(i);
    }
    for(int i=0;i<N;i++){
        if(entered[i] != required[i]){
            cnt++;
        }
    }
    if(cnt>2){
        cout << "NO";
    }
    else{
        cout << "YES";
    }
    return 0;
}

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

int main(){
    int n,w;
    scanf("%d %d",&n,&w);
    long long dp[w+1]={0};
    long long ans=0;
    for (int i=0;i<n;i++) {
        long long  a,b;
        scanf("%lld %lld",&a,&b);
        for (int j=w-a;j>0;j--) {
            if (dp[j]!=0) dp[j+a]=max(dp[j+a],dp[j]+b);
        }
        dp[a]=max(dp[a],b);
    }
    for (int i=0;i<w+1;i++) ans=max(ans,dp[i]);
    printf("%lld\n",ans);
    return 0;
}


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

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

typedef long long ll;
typedef pair<int, int> P;

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  map<string, int> a;
  int q;
  cin >> q;
  vector<int> ans;
  rep(i,q) {
    int command; cin >> command;
    if (command == 0) {
      string key;
      int x;
       cin >> key >> x;
      a[key] = x;
    } else if (command == 1) {
      string key; cin >> key;
      ans.push_back(a[key]);
    } else if (command == 2) {
      string key; cin >> key;
      a.erase(key);
    }
  }

  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 27840
#include<iostream>
#include<cctype>

using namespace std;
int main(){
    string x;
    
    while(1){
       
        int sum = 0;
        cin >> x;
        if(x == "0")break;
        
        for (int i = 0; i < x.size(); i++){
            int a = x[i] - '0';
            sum += a;
        }
        
        cout << sum << endl;
        
     
        
        
    }return 0;
}


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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N, K;
vector<ll> a;
vector<ll> sum;
vector<ll> v;
int dp[1000][1000];

void init()
{
	cin >> N >> K;
	CINV(a, N);
	sum.RS(N+1);
	sum[0] = 0;
	rep(i, N)  sum[i+1] = sum[i] + a[i];
	rep(i, N) reps(j, i, N) dp[i][j] = 1;
}

bool ch(ll x)
{
	int cnt = 0;
	rep(i, N) {
		reps(j, i, N) {
			if (dp[i][j] == 0) continue;
			ll t = sum[j+1] - sum[i];
			if (t & x) cnt++;
		}
	}
	return cnt >= K;
}

void del(ll x)
{
	rep(i, N) {
		reps(j, i, N) {
			ll t = sum[j+1] - sum[i];
			if ((t & x) == 0) dp[i][j] = 0;
		}
	}
}

ll calc()
{
	bool f = false;
	ll res = 0;
	ll ma;
	for (ll x = 1; x < (1LL << 60); x <<= 1) {
		if (ch(x)) {
			f = true;
			ma = x;
		}
	}
	if (!f) return 0;
	for (; ma; ma >>= 1) {
		if (ch(ma)) {
			del(ma);
			res += ma;
		}
	}
	return res;
}

void solve()
{
	cout << calc() << endl;
}




Measured memory_bytes: 4224
my ($N, $M) = map {$_ + 0} split(/\s+/o, <>);
my $R;
my $numF;
my $numT = 0;
foreach my $i (0..$M-1) {
  my ($p, $s) = split(/\s+/o, <>);
  if ( !defined($R->{$p}->{'done'})) {
    $R->{$p}->{'done'} = 0;
    $numF->{$p} = 0;
  }
  next if ( $R->{$p}->{'done'} );
  if ( $s eq 'WA' ) {
    $numF->{$p}++;
  } else {
    $numT++;
    $R->{$p}->{'done'} = 1;
  }
}
my $numFtot = 0;
foreach my $p (keys %{$numF}) {
  $numFtot += $numF->{$p} if ( $R->{$p}->{'done'} );
}
print "$numT $numFtot\n";

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

int N;
int dp[1010][1010], memo[1010], acc[1010], c[1010], w[1010];

int rec(int l, int r) {
    if (dp[l][r] != -1) {
        return dp[l][r];
    }

    if (r - l == 1) {
        return dp[l][r] = 1;
    }

    int res = 0;
    if (rec(l + 1, r) && acc[r] - acc[l + 1] <= c[l]) res = 1;
    if (rec(l, r - 1) && acc[r - 1] - acc[l] <= c[r - 1]) res = 1;

    return dp[l][r] = res;
}

int main() {
    int N;
    cin >> N;
    REP(i, N) {
        cin >> c[i] >> w[i];
        acc[i + 1] = w[i];
        acc[i + 1] += acc[i];
    }

    FILL(dp, -1);
    rec(0, N);
    FILL(memo, iINF);
    memo[0] = 0;

    for (int i = 1; i < N + 1; i++) {
        for (int j = 0; j < i; j++) {
            if (dp[j][i] == 1) {
                memo[i] = min(memo[i], memo[j] + 1);
            }
        }
    }

    cout << memo[N] << endl;

    return 0;
}


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

namespace mondai0049
{
	class Program
	{
		static void Main(string[] args)
		{
			int	a_sum	= 0;
			int	b_sum	= 0;
			int	ab_sum	= 0;
			int	o_sum	= 0;
			
			while( true ) {
				var	s	= Console.ReadLine();
				if( s == null ) {
					break;
				}
				var	ss	= s.Split( ',' );
				if( ss[ 1 ] == "A" ) {
					a_sum++;
				} else if( ss[ 1 ] == "B" ) {
					b_sum++;
				} else if( ss[ 1 ] == "AB" ) {
					ab_sum++;
				} else {
					o_sum++;
				}
			}

			Console.WriteLine( a_sum );
			Console.WriteLine( b_sum );
			Console.WriteLine( ab_sum );
			Console.WriteLine( o_sum );
		}
	}
}

Measured memory_bytes: 5512
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();

        TreeMap<Long, Long> map = new TreeMap<>();
        for(int i = 0; i < n; i++) {
        	long a = scan.nextLong();
        	long b = scan.nextLong();
        	if(map.containsKey(a)) {
        		map.put(a, map.get(a) + b);
        	}else {
        		map.put(a, b);
        	}
        }

        long ans = 0;
        for(long i: map.keySet()) {
        	if(m >= map.get(i)) {
        		ans += i * map.get(i);
        		m -= map.get(i);
        	}else {
        		ans += i * m;
        		m -= m;
        	}

        	if(m ==0)
        		break;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 100116
#include<bits/stdc++.h>
using namespace std;
int m,d,ans;
int main()
{
	while(cin>>m>>d)
	{
		for(int i=4;i<=m;i++)
		{
			for(int j=22;j<=d;j++)
			{
				if(j%10>=2&&j/10>=2)
					if((j%10)*(j/10)==i)
						ans++;
			}
		}
		cout<<ans<<'\n';
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;
const int INF = 1e16;
struct  edge{int to, cost;};
using Graph = vector<vector<edge> >;

void dij(Graph& G, int start, vector<int> &dist){
  priority_queue<P, vector<P>, greater<P> > que;
  for(int i = 0; i < dist.size(); i++){
    dist[i] = INF;
  }
  dist[start] = 0;
  que.push(P(0, start));
  
  while(!que.empty()){
    P p = que.top(); que.pop();
    int next = p.second;
    if(dist[next] < p.first) continue;
    for(int i = 0; i < G[next].size(); i++){
      edge e = G[next][i];
      if(dist[next] + e.cost < dist[e.to]){
        dist[e.to] = dist[next] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
}

signed main(){
  int n, m, s, t; cin >> n >> m >> s >> t; --s; --t;
  Graph Gy(n), Gs(n);
  for(int i = 0; i < m; i++){
      int u, v, a, b; cin >> u >> v >> a >> b;
      --u; --v;
      edge e1 = {u, a}, e2 = {u, b},  e3 = {v, a}, e4 = {v, b};
      Gy[v].push_back(e1), Gs[v].push_back(e2), Gy[u].push_back(e3);
      Gs[u].push_back(e4); 
  }
  vector<int> money(n), dists(n), disty(n);
  dij(Gy, s, disty);
  dij(Gs, t, dists);
  for(int i = 0; i < n; i++) money[i] = dists[i] + disty[i];
  vector<int> min_money(n);
  min_money[n - 1] = money[n - 1];
  for(int i = n - 2; i >= 0; i--){
      min_money[i] = min(min_money[i + 1], money[i]);
  }
  for(int i = 0; i < n; i++){
      cout << 1000000000000000 - min_money[i] << endl;
  }
}

Measured memory_bytes: 20352
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    const int MAX_N = (int) 1e7 + 10;
    vector<ll> res(MAX_N, 2);
    res[1] = 1;
    for (ll i = 2; i < MAX_N; i++) {
        for (ll j = 2 * i; j < MAX_N; j += i) {
            res[j]++;
        }
    }
    ll n; cin >> n;
    ll tot = 0;
    for (int i = 1; i <= n; i++) {
        tot += i * res[i];
    }
    cout << tot << "\n";
}


Measured memory_bytes: 81272
package main

import (
	"fmt"
)

func main() {
	var coin500, coin100, coin50, total int
	fmt.Scan(&coin500, &coin100, &coin50, &total)

	ans := 0
	for i := 0; i <= coin500; i++ {
		for j := 0; j <= coin100; j++ {
			r := total - (500*i + 100*j)
			if r >= 0 && r%50 == 0 {
				if r/50 <= coin50 {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 123456
#define mod 1000000007

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

int n;
string s;
ll dp[3003][3003];

ll sum(int idx, int l, int r) {
	if(r < l) return 0;
	return add(dp[idx][r], mod - dp[idx][l-1]);
}

int main() {
	// ll start = clock();
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n >> s;
	s = "#" + s;

	memset(dp, 0, sizeof dp);

	if(s[1] == '<') dp[2][2] = 1;
	else dp[2][1] = 1;

	for(int i=3; i<=n; i++) {
		
		for(int j=1; j<i; j++) dp[i-1][j] = add(dp[i-1][j], dp[i-1][j-1]);

		for(int last = 1; last <= i; last++) {
			if(s[i-1] == '<') {
				dp[i][last] = sum(i-1, 1, last-1);
			}
			else {
				dp[i][last] = sum(i-1, last, i-1);
			}
		}

	}
	ll ans = 0;
	for(int i=1; i<=n; i++) ans = add(ans, dp[n][i]);
	cout << ans << endl;
	// cerr << (clock() - start) / (CLOCKS_PER_SEC*1.0) << endl;
	return 0;
}

Measured memory_bytes: 70784
a,b,k=map(int,input().split())
if (b+1-a)<=2*k:
  for i in range(a,b+1):
    print(i)
else:
  for j in range(a,a+k):
    print(j)
  for l in range(b-k+1, b+1):
    print(l)

Measured memory_bytes: 3060
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <utility>
#include <set>

using llint = long long int;
using namespace std;

namespace CsF {
#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define FOR(I,J,K) for(int I = 0;I < J;I+=K)

	string ConvertBit(int N, int e) {
		string s = "";
		int r = 0;
		while (N != 0) {
			r = N % e;
			s = to_string(r) + s;
			N -= r;
			N /= e;
		}
		return s;
	}

	int GCD(int a, int b) {
		if (a < b)swap(a, b);
		int r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}

	int LCM(int a, int b) {
		int n = a * b;
		return (n / GCD(a, b));
	}

	int Count(string s, char c) {
		int cou = 0;
		FOR(i, s.length(), 1) {
			if (s[i] == c)cou++;
		}
		return cou;
	}

	vector<int> SieveOfEratosthenes(int N) {
		vector<bool> memo(N + 1);
		vector<int> ret;
		memo[0] = true;
		memo[1] = true;
		for (int i = 2; i < N; i++) {
			if (memo[i])continue;
			ret.push_back(i);
			for (int b = 2; true; b++) {
				if (i*b <= N) {
					memo[i*b] = true;
				}
				else break;
			}
		}
		return ret;
	}

	vector<int> SpInput(int N) {
		vector<int> ret(N);
		FOR(i, N, 1) { cin >> ret[i]; }
		return ret;
	}
}

using namespace CsF;


int main() {
	int N;
	cin >> N;
	int A[110];
	int B[110];
	FOR(i, N, 1) { cin >> A[i]; }
	FOR(i, N, 1) { cin >> B[i]; }
	int dp[110][2];
	FOR(i, N + 1, 1) { dp[i][0] = -MAX_INT; dp[i][1] = -MAX_INT; }
	dp[0][0] = A[0];
	FOR(i, N + 1, 1) {
		dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + A[i + 1]);
		dp[i][1] = max(dp[i][1], dp[i][0] + B[i]);
		dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + B[i + 1]);
	}
	cout << dp[N - 1][1] << "\n";


	return 0;
}



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

int main(){
  int N;
  cin >> N;
  int64_t L2 = 2, L1 = 1, LN;
  
  for(int i = 1; i < N; i++){
    LN = L2 + L1;
    L2 = L1;
    L1 = LN;
  }
  
  if(N == 1)
    cout << 1 << endl;
  else
    cout << LN << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rp(i,j) for(long long i=0;i<j;i++)
#define rep(i,j,k) for(long long i=j;i<k;i++)
#define mod 1000000007
#define NIL -1
#define MAX 100000
typedef long long ll;
struct Node{int parent,left,right;};
struct Node T[MAX];
int n,D[MAX];
void setDepth(int u,int p){
    D[u]=p;
    if(T[u].right!=NIL)setDepth(T[u].right,p);
    if(T[u].left!=NIL)setDepth(T[u].left,p+1);
}
void print(int i){
    cout<<"node "<<i<<": parent = "<<T[i].parent;
    cout<<", depth = "<<D[i];
    if(T[i].parent==NIL)cout<<", root, ";
    else if(T[i].left==NIL)cout<<", leaf, ";
    else cout<<", internal node, ";
    cout<<"[";
    int c=T[i].left;
    while(c!=NIL){
        if(c!=T[i].left)cout<<", ";
        cout<<c;
        c=T[c].right;
    }
    cout<<"]"<<endl;
}
int main(){
    cin>>n;
    int id,k,c,l,r;
    rp(i,n)T[i].parent=T[i].left=T[i].right=NIL;
    rp(i,n){
        cin>>id>>k;
        rp(j,k){
            cin>>c;
            if(j==0)T[id].left=c;
            else T[l].right=c;
            l=c;
            T[c].parent=id;
        }
    }
    rp(i,n)if(T[i].parent==NIL)r=i;
    setDepth(r,0);
    rp(i,n)print(i);
}


Measured memory_bytes: 7748
n = gets.to_i
S = gets.split(" ").map(&:to_i)
q = gets.to_i
T = gets.split(" ").map(&:to_i)

a = 0
for i in 0..q-1
left = 0
right = n
  while left < right
    mid = (left+right)/2
    if S[mid] == T[i]
      a += 1
      break
    elsif S[mid] > T[i]
      right = mid
    else
      left = mid +1
    end
  end
end

puts a

Measured memory_bytes: 17364
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 1e6 + 100, OO = 1e8 + 100, M = 1e9 + 7, P = 6151, sq = 500, lg = 23;
typedef pair <int, int> pii;

int32_t main() {
	use_fast;
	string s;
	cin >> s;
	vector <pii> v;
	if(s[0] == '<')
		v.pb({1, 0});
	else
		v.pb({1, 1});
	for(int i = 1; i < s.size(); i++) {
		if(s[i] == s[i - 1])
			v[v.size() - 1].ff++;
		else {
			if(s[i] == '<')
				v.pb({1, 0});
			else
				v.pb({1, 1});
		}
	}
	int t = 0, ans = 0;
	if(v[0].ss == 1) {
		t = v[0].ff;
		ans += v[0].ff;
	}
	for(int i = 0; i < (int)v.size(); i++) {
		pii u = v[i];
		if(u.ss == 1) {
			ans += t * (t - 1) / 2;
			continue;
		}
		else {
			int f = u.ff;
			ans += f * (f + 1) / 2;
			if(i == (int)v.size() - 1)
				continue;
			if(v[i + 1].ff <= f) {
				t = v[i + 1].ff;
				continue;
			}
			else {
				ans += (v[i + 1].ff - f);
				t = v[i + 1].ff;
				continue;
			}
		}
	}
	cout << ans << endl;
	return 0;
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

Measured memory_bytes: 6804
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int T=0;
    string str;
    string s1,s2,s3="";
    cin>>s1>>s2;
    for(int i=0;i<s1.size();i++)
    {
        s3+=s1[i];
        str="";
        for(int j=1;j+i<s1.size();j++)
        {
            //if(i+j>=s1.size())break;
            str=str+s1[j+i];
            //cout<<str<<endl;
        }
        str=str+s3;

        if(str==s2){T=1;break;}//cout<<str<<" "<<s2<<endl;

    }
    if(T==0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;

}


Measured memory_bytes: 256
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
m = 1
for i in range(n):
  m = m * a[i] // gcd(m, a[i])
m = m - 1
f = 0
for i in range(n):
  f += m % a[i]
print(f)

Measured memory_bytes: 5344
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,m,a,b,count[55];
    cin >> n >> m;
    for(int i = 0;i <= 50;i++){count[i] = 0;}
    for(int i = 0;i < m;i++)
    {
        cin >> a >> b;
        count[a]++;
        count[b]++;
    }
    for(int i = 1;i <= n;i++)
    {
        cout << count[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    static int max;
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int q = scanner.nextInt();
        int[][] a = new int[q][4];
        max = 0;
        for(int i = 0; i < q; i++){
            a[i][0] = scanner.nextInt();
            a[i][1] = scanner.nextInt();
            a[i][2] = scanner.nextInt();
            a[i][3] = scanner.nextInt();
        }
        dfs(0, new ArrayList<Integer>(), n,m,q,a);
        System.out.println(max);
    }

    public static void dfs(int idx, List<Integer> A, int n, int m, int q, int[][] a){
        if(idx == n){
            if(A.size() < n)return;
            int score = 0;
            for(int i = 0; i < q; i++){
                if(A.get(a[i][1]-1) - A.get(a[i][0]-1) == a[i][2]){
                    score += a[i][3];
                }
            }
            if(max < score){max = score;}
            return;
        }else{
            int val = 1;
            if(idx-1 >= 0){
                val = A.get(idx-1);
            }
            for(int i = val; i <= m; ++i){
                A.add(i);
                dfs(idx+1, A, n, m, q, a);
                A.remove(A.size()-1);
            }
        }
    }
}



Measured memory_bytes: 39372
# -*- coding: utf-8 -*-

steps = []
step = int(input())
while step != 0:
    steps.append(step)
    step = int(input())

max_step = max(steps)
nums = [1,2,4] + [0 for _ in range(3,max_step)]
for i in range(3,max_step):
    nums[i] = nums[i-1] + nums[i-2] + nums[i-3]

for step in steps:
    year_minus = nums[step-1] // -3650
    print(str(-year_minus))

Measured memory_bytes: 6720
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3
1
4
3
---+/
/+---test
2
5
5
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;

  struct Pair { long i, v; }

  Pair[2] M;
  foreach (i; 0..N) {
    const v = readln.chomp.to!long;
    if (M[0].v <= v) {
      swap(M[0], M[1]);
      M[0] = Pair(i, v);
    } else if (M[1].v <= v) {
      M[1] = Pair(i, v);
    }
  }

  auto ans = new long[N];
  foreach (i; 0..N) {
    const p = M[0].i != i? M[0]: M[1];
    p.v.writeln;
  }
}


Measured memory_bytes: 5756
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)
	answer := doesWin(a, b, c, d)
	fmt.Println(answer)
}

func doesWin(hpA, attackA, hpB, attackB int) string {
	asTurn := true
	for ; hpA > 0 && hpB > 0; asTurn = !asTurn {
		if asTurn {
			hpB -= attackA
		} else {
			hpA -= attackB
		}
	}
	if hpA > 0 {
		return "Yes"
	}
	return "No"
}


Measured memory_bytes: 1816
#include<iostream> 
#include<cstdio>
#include<algorithm>
#include<limits>
using namespace std;
inline int read()
{
	int f=1;char c=getchar();int x=0;
	while(c<'0'||c>'9') {if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}x*=f;
}
int x[20000],y[20000],xcp,ycp,n,m,xm=-9999999,ym=9999999;
int main()
{
	scanf("%d %d %d %d",&n,&m,&xcp,&ycp);
	for(int i=1;i<=n;i++) {int l;scanf("%d",&l);xm=max(xm,l);}
	for(int i=1;i<=m;i++) {int l;scanf("%d",&l);ym=min(ym,l);}
	if(max(xm,xcp)+1<=min(ym,ycp)) printf("No War");
	else printf("War");
	return 0;
}


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

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

    if(a == b)
        cout << a + b << endl;

    else if(a > b)
        cout << 2 * a - 1 << endl;

    else cout << 2 * b - 1 << endl;

}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int counter = 0;
        if(a != b && a != c) counter = 3;
        if((a != b && a == c) || (a == b && a != c) || (b == c && a != c)) counter =2;
        if(a == b && a == c) counter = 1;

        System.out.println(counter);

    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}

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

int main( )
{
    int n, i;
    cin >> n;
    long long int s = 0;
    for (i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        s += i;
    }
    cout << s << '\n';
    return 0;
}


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

using namespace std;

struct Task{
  string name;
  int tim;
};

template<typename T>
class Q{
  T* t;
  int head,tail,n;
  public:
  Q(int _n) : head(0),tail(1),n(_n) {
    t = new T[n];
  }
  ~Q(){
    delete [] t;
  }
  void enqueue(T _t){
    //if(head==tail) throw 1;
    t[(tail-1)%n] = _t;
    tail++;
  }
  T dequeue(){
    if(head+1==tail) throw 2;
    T _t =t[head%n];
    head++;
    return _t;
  }
};

int main(){
  int n,q; cin>>n>>q;
  Q<Task> que(n);
  for(int i=0;i<n;i++){
    Task t;
    cin>>t.name>>t.tim;
    que.enqueue(t);
  }

  int sumq = 0;
  try{
    while(true){
      Task task;
      task = que.dequeue();
      if(task.tim > q){
        task.tim -= q;
        que.enqueue(task);
        sumq += q;
      }else{
        cout<<task.name<<' '<<sumq+task.tim<<endl;
        sumq += task.tim;
      }
    }
  }catch(int err){
  } 
}

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

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

int main(){
	int N,A,B,C,X;
	while(cin>>N>>A>>B>>C>>X,N){
		int c=0;
		bool f=true;
		rep(i,N){
			int y;
			cin>>y;
			for(;;c++){
				if(c>10000){
					f=false;
					break;
				}
				if(X==y) break;
				X=(A*X+B)%C;
			}
			X=(A*X+B)%C;
			c++;			

		}
		if(f) cout<<c-1<<endl;
		else cout<<-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::{max, min};

fn main() {
    let s: String = read();
    let cv: Vec<char> = s.chars().collect();

    let mut cntv: Vec<u64> = vec![];

    let mut idx: u64 = 0;
    let mut tmp: u64 = 0;
    'l: loop {
        let l = cv.len() as u64;
        loop {
            if idx >= l || cv[idx as usize] != '<' {
                break;
            }
            idx += 1;
        }
        cntv.push(idx - tmp);
        tmp = idx;
        loop {
            if idx >= l || cv[idx as usize] != '>' {
                break;
            }
            idx += 1;
        }
        cntv.push(idx - tmp);
        tmp = idx;
        if idx >= l {
            break;
        }
    }

    let mut ans: u64 = 0;
    for i in 0..cntv.len() / 2 {
        let j = 2 * i;
        let k = j + 1;
        let n = min(cntv[j], cntv[k]);
        let m = max(cntv[j], cntv[k]);
        if n > 0 {
            ans += n * (n - 1) / 2;
        }
        ans += m * (m + 1) / 2;
    }

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


Measured memory_bytes: 12020
#include<bits/stdc++.h>
using namespace std;
const int INF=1001001001;
int dp[100010];
int N;

int main(){
    cin>>N;
    fill_n(dp,N+2,INF);

    for(int i=0;i<N;i++){
        int A;cin>>A;
        int lb=-1,ub=N+2;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if(dp[mid]>=A)ub=mid;
            else lb=mid;
        }
        dp[ub]=A;
    }

    int lb=-1,ub=N+2;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(dp[mid]>=INF)ub=mid;
        else lb=mid;
    }

    cout<<ub<<endl;
    return 0;
}

Measured memory_bytes: 1548
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string S;
    cin >> S;
    string tmp = "CODEFESTIVAL2016";
    ll cnt = 0;
    rep(i, tmp.size()) {
        if (S[i] != tmp[i]) cnt++;
    }
    print(cnt);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
import sys
import numpy as np

n,k = map(int, sys.stdin.readline().rstrip().split())
h = np.array(list(map(int, sys.stdin.readline().rstrip().split())))

dp = np.zeros(n, dtype=np.int)

for i in range(1,n):
  if i < k:
    dp[i] = np.min(dp[:i] + np.abs(h[i]-h[:i]))
  else:
    dp[i] = np.min(dp[i-k:i] + np.abs(h[i]-h[i-k:i]))

print(dp[n-1])

Measured memory_bytes: 22908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k,q;
ll d[5010];
ll p[5010];
ll b[5010];
ll n,m,x;

void solve() {
    for (int i = 1; i <= k; i++) {
        p[i] = d[i-1] % m;
        if (p[i] == 0) p[i] = m;
    }
    b[0] = 0;
    for (int i = 1; i <= k; i++) {
        b[i] = b[i-1] + p[i];
    }
    ll ans = n - 1;
    ll sum = x % m;
    sum += (n - 1) / k * b[k];
    ans -= sum / m;
    sum %= m;
    sum += b[(n - 1) % k];
    ans -= sum / m;
    // cout << sum % m << endl;
    cout << ans << endl;
}

int main() {
    cin >> k >> q;
    for (int i = 0; i < k; i++) cin >> d[i];
    for (int i = 0; i < q; i++) {
        cin >> n >> x >> m;
        solve();
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
  int N;

  cin >> N;
  
  int max = 0;
  int ans = 1;
  int num = N;
  int count=0;

  for(int i = 1;i <= N;i++){
    num = i;
    while(num % 2 == 0){
      num /= 2;
      count++;
    }

    if(count > max){
      max = count;
      ans = i;
    }

    count = 0;
  }

  cout << ans << endl;

  return 0;
}


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

int min2(int a, int b)
{
  return (a > b) ? b : a;
}

int main(void)
{
  int n, k;
  int h[100000];
  long dp[100000];

  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++)
    scanf("%d", &h[i]);

  for (int i = 1; i <= n - 1; i++) {
    long min = 1000000000;
    for (int j = 1; j <= min2(k, i) ; j++) {
      if (dp[i - j] + abs(h[i] - h[i - j]) < min)
	min = dp[i - j] + abs(h[i] - h[i - j]);
    }
    dp[i] = min;
  }
  printf("%ld\n",  dp[n - 1]);
}

Measured memory_bytes: 1280
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        char c = a.charAt(0);
        char d = b.charAt(0);
        if(c > d){
            System.out.println(">");
        }
        else if (c < d){
            System.out.println("<");
        }
        else {
            System.out.println("=");
        }
    }
}


Measured memory_bytes: 21716
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int N = Integer.parseInt(line[0]);
        int A = Integer.parseInt(line[1]);
        int B = Integer.parseInt(line[2]);
        int max = A+B;
        
        String[] student = br.readLine().split("");
        int passed = 0,
            foreign = 0;
        for(int i=0;i<N;i++){
        	if(passed >= max) System.out.println("No");
        	else{
        		if(student[i].equals("a")) {
        			System.out.println("Yes");
        			passed++;
        		}
        		else if(student[i].equals("b")){
        			if(foreign < B){
        				System.out.println("Yes");
        				passed++;
        				foreign++;
        			}
        			else System.out.println("No");
        		}
        		else System.out.println("No");
        	}
        }
        
        
    }
}


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

int main() {
	while(1){
		int h,w;
		cin >> h >>w;
		if(h==0 && w==0) break;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


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

using namespace std;

#define N 800
#define LL long long

const LL mod=1000000007;
LL n,m,a[N],b[N],f[N][N],g[N][N];

void upd(LL &x,LL y){x=(x+y%mod+mod)%mod;}

int main(){
	scanf("%lld",&n);
	for (LL i=0;i<n*2;++i) scanf("%lld",a+i);
	for (LL i=0;i<n;++i){
		LL x=a[i<<1],y=a[i<<1|1];
		if (x>0&&y>0){b[x]=b[y]=-1; continue;}
		if (x<0&&y<0){++m; continue;}
		if (x>0) b[x]=1;
		if (y>0) b[y]=1;
	}
	f[0][0]=1;
	for (LL i=1,x=0,y=0;i<=n*2;++i){
		if (b[i]<0) continue;
		memset(g,0,sizeof g);
		if (b[i]>0){
			for (LL j=0;j<=x+y;++j)
				for (LL k=0;k<=x+y;++k){
					upd(g[j+1][k],f[j][k]);//m
					if (k) upd(g[j][k-1],f[j][k]*k);//m
				}
			++x;
		}
		else{
			for (LL j=0;j<=x+y;++j)
				for (LL k=0;k<=y;++k){
					if ((j-k-x+y)>=0) upd(g[j+1][k],f[j][k]);//m-1
					if (j) upd(g[j-1][k],f[j][k]);//m
					upd(g[j][k+1],f[j][k]);//m
				}
			++y;
		}
		memcpy(f,g,sizeof f);
	}
	for (int i=1;i<=m;i++) f[0][0]=1LL*f[0][0]*i%mod;
	printf("%lld\n",f[0][0]);
	
	return 0;
}

Measured memory_bytes: 10240
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

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

    vector<long> p(n);
    for (long i = 0; i < n; ++i) {
        cin >> p[i];
    }

    int counter = 0;
    for (long i = 1; i < n - 1; ++i) {
        vector<long> check(3);
        check[0] = p[i - 1];
        check[1] = p[i];
        check[2] = p[i + 1];
        sort(check.begin(), check.end());
        if (check[1] == p[i]) {
            ++counter;
        }
    }

    cout << counter << endl;

    return 0;
}


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

int main() {
   int n,k;
   cin >> n >> k;
   vector<int>p(n);
   for (int i = 0; i < n; i++)cin >> p.at(i);
   int ans = 0;
   sort(p.begin(), p.end());
   for (int i = 0; i < k; i++) {
      ans = ans + p.at(i);
   }
   cout << ans <<endl;
}


Measured memory_bytes: 3580
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();
		double time = (double)D/(double)S;
		if((double)T >= time) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 35876