akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void) {
  int n,m,l,i,j,k;
  int A[100][100] = {0}, B[100][100] = {0};
  long C[100][100] = {0};
  scanf("%d %d %d", &n, &m, &l);
  for (i=0; i<n; i++) {
    for (j=0; j<m; j++) {
      scanf("%d",&A[i][j]);
    }
  }
  for (j=0; j<m; j++) {
    for (k=0; k<l; k++) {
      scanf("%d",&B[j][k]);
    }
  }
  for (i=0; i<n; i++) {
    for (j=0; j<l; j++) {
      for (k=0; k<m; k++) {
        C[i][j] += A[i][k] * B[k][j];
      }
    }
  }
  for (i=0; i<n; i++) {
    for (j=0; j<l-1; j++) {
      printf("%ld ",C[i][j]);
    }
    printf("%ld\n",C[i][l-1]);
  }
  return 0;
}

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

int main(void){
	char data[1000010];
	long int m, n, ans, count;


	while (true){
		ans = 0;

		scanf("%ld", &n);
		if (n == 0){ break; }
		n--;

		scanf("%ld", &m);
		scanf("\n");
		gets(data);


		count = 0;
		for (int i = 0; i < m; i++){
			if (data[i] == 'I' && data[i + 1] == 'O'){
				i++;
				count++;
			}
			else if (data[i] == 'I'){
				if (count > n){ ans += count - n; }
				count = 0;
			}
			else{
				count--;
				if (count > n){ ans += count - n; }
				count = 0;
			}
			
		}
		count--;
		if (count > n){ ans += count - n; }


		printf("%ld\n", ans);

	}

	return 0;
}

Measured memory_bytes: 2008
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=200005;

int main()
{
    IO;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(abs(a-b)<=d&&abs(c-b)<=d)re cout<<"Yes",0;
    if(abs(a-c)<=d)re cout<<"Yes",0;puts("No");
    re 0;
}

Measured memory_bytes: 892
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var X = Scanner.Scan<int>();
            Console.WriteLine(X == 1 ? 0 : 1);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28388
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

const int M = 1e9+7;
int n, k;
vector<int> edge[110000];
queue<int> q;
bool done[110000];
long long ans;

int main()
{
  cin >> n >> k;
  for (int i = 0; i < n-1; i++) {
    int a, b;
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  
  done[1] = true;
  ans = k;
  
  int cnt = 0;
  for (int v: edge[1]) {
    q.push(v);
    done[v] = true;
    ans = ans * (k-cnt-1) % M;
    cnt++;
  }
  
  while(q.size()) {
    int u = q.front(), cnt = 0;
    for (int v: edge[u]) {
      if (done[v]) continue;
      q.push(v);
      done[v] = true;
      ans = ans * (k-cnt-2) % M;
      cnt++;
    }
    q.pop();
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6904
import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

N = int(sys.stdin.readline())
A = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

A = np.array(A, dtype=float)

useless = np.zeros((N, N), dtype=bool)
impossible = np.zeros((N, N), dtype=bool)
for via in range(N):
    # R[i][j]: i -> via -> j の距離
    R = sum(np.meshgrid(A[via], A[via]))
    R[via] = np.inf
    R[:, via] = np.inf
    useless |= R == A
    impossible |= R < A
if impossible.sum():
    print(-1)
else:
    print(int(A[~useless].sum() // 2))


Measured memory_bytes: 17796
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;
 
 
int main() {
  int x, N;
  
  cin >> x >> N;
  
  if(N==0) {
    cout << x << endl;
  }
  else {
  vector<int> plist(N);
  for (int i = 0; i<N; i++) {
    int p;
    cin >> p;
    plist.at(i) = p;
  }
  int k = 0, ans, jud;
  
  while(true) {
    ans = x-k;
    for (int i = 0; i<N; i++) {
      jud = 0;
      if (plist.at(i)==ans) {
        jud++;
        break;
      }
    }
    
    if (jud==0) {
      break;
    }
    else {
      ans = x+k;
      for (int i = 0; i<N; i++) {
        jud = 0;
        if (plist.at(i)==ans) {
          jud++;
          break;
        }
      }
      
      if (jud==0) {
        break;
      }
      else {
        k++;
      }
    }
  }
  
  cout << ans << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n,m; cin >> n >> m;
    char a[n][n],b[m][m];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) cin >> a[i][j];
    }
    for(int i=0; i<m; i++){
        for(int j=0; j<m; j++) cin >> b[i][j];
    }

//解説みて書き直し
    bool exist=false;
    for(int yi=0; yi<n; yi++){
        for(int xi=0; xi<n; xi++){
            if(yi+m-1>=n or xi+m-1>=n) continue;

            bool match=true;
            for(int y=0;y<m;y++){
                for(int x=0;x<m;x++){
                    if(a[yi+y][xi+x]!=b[y][x]) match=false;
                }
            }
            if(match) exist=true;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int a[100009];
mint p2[100009],p3[100009];

int main(){
  string s;
  cin>>s;
  vector<int>a(s.size());
  reverse(s.begin(),s.end());
  int next=1;
  rep(i,s.size()){
    int x=s[i]-'0';
    x+=next;
    a[i]=x%2;
    next=x/2;
  }
  if(next)a.push_back(1);

  p2[0]=p3[0]=1;
  for(int i=1;i<=a.size();i++){
    p2[i]=p2[i-1]*2;
    p3[i]=p3[i-1]*3;
  }

  mint ans=0;
  int cnt=0;
  for(int i=(int)a.size()-1;i>=0;i--){
    if(a[i]==0)continue;
    ans+=p3[i]*p2[cnt];
    cnt++;
  }

  cout<<ans.x<<endl;
  return(0);
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  string days[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  for (int i = 0; i < 7; ++i) {
    if (s == days[i]) {
      cout << 7 - i << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  double a,b,c,d,e,f,x,y;
  while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
    x = (e*c-b*f)/(e*a-b*d);
    y = (f*a-c*d)/(e*a-b*d);
    if(x==-0) x=0;
    if(y==-0) y=0;
    printf("%.3lf %.3lf\n",x,y);
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll H, W;
    cin >> H >> W;
    string Si;
    vector<string> S;
    for(int i=0;i<H;i++){
        cin >> Si;
        S.push_back(Si);
    }
    vector<vector<ll>> lH(H, vector<ll>(W,0));
    vector<vector<ll>> lW(H, vector<ll>(W,0));
    for(int i=0;i<H;i++){
        ll nl=0;
        for(int j=0;j<W;j++){
            int j2 = j;
            while(j<W&&S[i][j]=='.') j++;
            for(int k=j2;k<j;k++) lW[i][k]=j-j2;
        }
    }
    for(int j=0;j<W;j++){
        ll nl=0;
        for(int i=0;i<H;i++){
            int i2 = i;
            while(i<H&&S[i][j]=='.') i++;
            for(int k=i2;k<i;k++) lH[k][j]=i-i2;
        }
    }
    ll res = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            auto v = lW[i][j] + lH[i][j] - 1;
            if(v>res) res=v;
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 67072
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let (a, b, c, x): (u32, u32, u32, u32) = (sc.read(), sc.read(), sc.read(), sc.read());

    use itertools::iproduct;
    println!(
        "{}",
        iproduct!(0..=a, 0..=b, 0..=c)
            .filter(|(i, j, k)| 500 * i + 100 * j + 50 * k == x)
            .count()
    );
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  if(K<=A)cout<<K<<endl;
  if(A<K&&K<=A+B)cout<<A<<endl;
  if(A+B<K)cout<<A-(K-A-B)<<endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

int N, M;
vector<pair<int, int>> edge_list;
vector<vector<int>> adj;
vector<vector<bool>> reach;

void reach_dfs(int source, int node) {
    if (reach[source][node])
        return;

    reach[source][node] = true;

    for (int neighbor : adj[node])
        reach_dfs(source, neighbor);
}

vector<vector<bool>> reach_without;
vector<int> best_index;

void without_dfs(int index, int node) {
    if (best_index[node] >= 0)
        return;

    best_index[node] = index;

    for (int neighbor : adj[node])
        without_dfs(index, neighbor);
}

void solve_reach_without(int source) {
    reach_without[source][source] = true;
    int neighbors = adj[source].size();
    best_index.assign(N, -1);
    best_index[source] = N;

    for (int i = 0; i < neighbors; i++)
        without_dfs(i, adj[source][i]);

    for (int i = 0; i < neighbors; i++) {
        int neighbor = adj[source][i];

        if (best_index[neighbor] >= 0 && best_index[neighbor] != i)
            reach_without[source][neighbor] = true;
    }

    best_index.assign(N, -1);
    best_index[source] = N;

    for (int i = neighbors - 1; i >= 0; i--)
        without_dfs(i, adj[source][i]);

    for (int i = 0; i < neighbors; i++) {
        int neighbor = adj[source][i];

        if (best_index[neighbor] >= 0 && best_index[neighbor] != i)
            reach_without[source][neighbor] = true;
    }
}

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

    cin >> N >> M;
    edge_list.resize(M);
    adj.assign(N, {});

    for (pair<int, int> &edge : edge_list) {
        cin >> edge.first >> edge.second;
        edge.first--; edge.second--;
        adj[edge.first].push_back(edge.second);
    }

    reach.assign(N, vector<bool>(N, false));

    for (int i = 0; i < N; i++)
        reach_dfs(i, i);

    reach_without.assign(N, vector<bool>(N, false));

    for (int i = 0; i < N; i++)
        solve_reach_without(i);

    for (pair<int, int> &edge : edge_list) {
        bool answer1 = reach_without[edge.first][edge.second];
        bool answer2 = reach[edge.second][edge.first];
        cout << (answer1 ^ answer2 ? "diff" : "same") << '\n';
    }
}


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

int main() {
  
  char a,b;
  cin >> a >> b;
  
  if ( a < b ){
    cout << '<' << endl;
  }else if ( a > b ){
    cout << '>' << endl;
  }else{
    cout << '=' << endl;
  } 
  
}



Measured memory_bytes: 256
#include <cstdio>

int ps[20001];

int main(){
  int N;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    int P;
    scanf("%d",&P);
    ps[P-1]=i+1;
  }
  for(int i=0;i<N;i++){
    if(i) printf(" ");
    printf("%d",i*20001+ps[i]);
  }
  printf("\n");
  for(int i=0;i<N;i++){
    if(i) printf(" ");
    printf("%d",(int)1e9-i*20001);
  }
  printf("\n");
  return 0;
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n;
	cin >> n;
	vector<int> t(n);
	for (auto&& i : t) {
		cin >> i;
	}
	int sumt = accumulate(cbegin(t), cend(t), 0);
	int m;
	cin >> m;
	while (m--) {
		int p, x;
		cin >> p >> x;
		cout << sumt - t[p - 1] + x << "\n";
	}
}

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


Measured memory_bytes: 256
#include<stdio.h>

int n,pos;
int a[40],b[40];

void solve(int l,int r){
  if(l>r)return;
  if(l==r){
    if(b[l]==a[0])printf("%d",b[l]);
    else printf("%d ",b[l]);
    pos++;
    return;
  }

  int x=a[pos],i;
  pos++;
  for(i=l;i<=r;i++){
    if(b[i]==x)break;
  }
  solve(l,i-1);
  solve(i+1,r);
  
  if(x==a[0])printf("%d",x);
  else printf("%d ",x);
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=0;i<n;i++)scanf("%d",&b[i]);
  pos=0;
  solve(0,n-1);
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define MOD 998244353

//*
//遅延セグ木ここから
//↓ここを変える
typedef struct sayouso{ll a,b;}sayouso;
typedef struct atai{ll s,len;}atai;
//↑ここを変える

typedef struct node{sayouso T;atai x;}node;
node *lsegN,*lseg;
ll lsegNUM;

//↓ここから変える
sayouso sid={1,0};
atai aid={0,1};
atai xx(atai x,atai y){
	atai ret;
	ret.s=(x.s+y.s)%MOD;
	ret.len=x.len+y.len;
	return ret;
}
atai Tx(sayouso T,atai x){
	atai ret;
	ret.s=(T.a*x.s+T.b*x.len)%MOD;
	ret.len=x.len;
	return ret;
}
sayouso TT(sayouso S,sayouso T){
	sayouso ret;
	ret.a=S.a*T.a%MOD;
	ret.b=(S.b+S.a*T.b)%MOD;
	return ret;
}
//↑ここまで変える

//要素数(2ベキ)でこれを呼ぶ
void lseguse(ll n){
	lsegN=(node*)calloc(2*n,sizeof(node));
	lsegNUM=n;
	lseg=lsegN+lsegNUM;
	rep(i,0,lsegNUM){
		lseg[i].x=aid;
		lseg[i].T=sid;
	}
	for(int i=lsegNUM-1;i>0;i--){
		lsegN[i].x=xx(lsegN[2*i].x,lsegN[2*i+1].x);
		lsegN[i].T=sid;
	}
}
//lseg[i].xに値を与えてから初期化
void lseginit(){
	for(int i=lsegNUM-1;i>0;i--)lsegN[i].x=xx(lsegN[2*i].x,lsegN[2*i+1].x);
}
void lsegupdatesub(ll l,ll r,sayouso T,ll i,ll cl,ll cr){
	if(l>=r)return;
	//disjointなとき
	if(cr<=l||r<=cl)return;
	//完全に含むとき
	if(l<=cl&&cr<=r){
		lsegN[i].T=TT(T,lsegN[i].T);
		return;
	}
	//どちらでもないとき
	//遅延伝播
	lsegN[2*i  ].T=TT(lsegN[i].T,lsegN[2*i  ].T);
	lsegN[2*i+1].T=TT(lsegN[i].T,lsegN[2*i+1].T);
	//再帰的に更新
	ll cm=(cl+cr)/2;
	lsegupdatesub(l,r,T,2*i  ,cl,cm);
	lsegupdatesub(l,r,T,2*i+1,cm,cr);
	//自身のnodeを更新
	lsegN[i].x=xx(Tx(lsegN[2*i].T,lsegN[2*i].x),Tx(lsegN[2*i+1].T,lsegN[2*i+1].x));
	lsegN[i].T=sid;
}
void lsegupdate(ll l,ll r,sayouso T){lsegupdatesub(l,r,T,1,0,lsegNUM);}
atai lsegcalcsub(ll l,ll r,ll i,ll cl,ll cr){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return Tx(lsegN[i].T,lsegN[i].x);

	ll cm=(cl+cr)/2;
	//遅延伝播(変更はないので配るだけで良い)
	lsegN[2*i  ].T=TT(lsegN[i].T,lsegN[2*i  ].T);
	lsegN[2*i+1].T=TT(lsegN[i].T,lsegN[2*i+1].T);
	lsegN[i].x=Tx(lsegN[i].T,lsegN[i].x);
	lsegN[i].T=sid;

	//左側だけ
	if(r<=cm)return lsegcalcsub(l,r,2*i  ,cl,cm);
	//右側だけ
	if(cm<=l)return lsegcalcsub(l,r,2*i+1,cm,cr);
	//両方
	return xx(lsegcalcsub(l,r,2*i,cl,cm),lsegcalcsub(l,r,2*i+1,cm,cr));
}
atai lsegcalc(ll l,ll r){return lsegcalcsub(l,r,1,0,lsegNUM);}
//遅延セグ木ここまで
//*/

int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	lseguse(1<<19);
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		lseg[i].x.s=t;
	}
	lseginit();
	while(q--){
		int t,l,r;
		scanf("%d%d%d",&t,&l,&r);
		if(t==0){
			int a,b;
			scanf("%d%d",&a,&b);
			sayouso T={a,b};
			lsegupdate(l,r,T);
		}else{
			printf("%lld\n",lsegcalc(l,r).s);
		}
	}
}

Measured memory_bytes: 35596
#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(a+b >= 10) cout << "error" << endl;
    else cout << a+b << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

vec t(1, 0);
vec x(100010), y(100010);
vector<char> d(100010);

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

ll p_x(ll i, ll time){
    if(d[i] == 'L'){
        return x[i] - time;
    }else if(d[i] == 'R'){
        return x[i] + time;
    }else {
        return x[i];
    }
}

ll p_y(ll i, ll time){
    if(d[i] == 'D'){
        return y[i] - time;
    }else if(d[i] == 'U'){
        return y[i] + time;
    }else{
        return y[i];
    }
}

void search(bool ifx){
    ll lb = 0, ub = 1e+9, mi = 1e+9;
    rep(i,N) chmin(mi, (ifx ? x[i] : y[i]));
    while(ub - lb > 1){
        ll cen = (ub + lb) / 2, tmi = 1e+9;
        rep(i,N) chmin(tmi, (ifx ? p_x(i, cen) : p_y(i, cen)));
        (mi + cen == tmi ? lb : ub) = cen;
    }
    t.push_back(lb);
    mi += lb;
    ub = 1e+9;
    while(ub - lb > 1){
        ll cen = (ub + lb)/2, tmi = 1e+9;
        rep(i,N) chmin(tmi, (ifx ? p_x(i, cen) : p_y(i, cen)));
        (mi == tmi ? lb : ub) = cen;
    }
    t.push_back(lb);
    ll ma = -1e+9;
    rep(i,N) chmax(ma, (ifx ? x[i] : y[i]));
    lb = 0, ub = 1e+9;
    while(ub - lb > 1){
        ll cen = (ub + lb) / 2, tma = -1e+9;
        rep(i,N) chmax(tma, (ifx ? p_x(i, cen) : p_y(i, cen)));
        (ma - cen == tma ? lb : ub) = cen;
    }
    t.push_back(lb);
    ma -= lb;
    ub = 1e+9;
    while(ub - lb > 1){
        ll cen = (ub + lb) / 2, tma = -1e+9;
        rep(i,N) chmax(tma, (ifx ? p_x(i, cen) : p_y(i, cen)));
        (ma == tma ? lb : ub) = cen;
    }
    t.push_back(lb);
}

ll solve(ll time){
    ll xa, xi, ya, yi;
    xa = ya = -1e+9;
    yi = xi = 1e+9;
    rep(i,N){
        chmax(xa, p_x(i, time));
        chmax(ya, p_y(i, time));
        chmin(xi, p_x(i, time));
        chmin(yi, p_y(i, time));
    }
    return (ya - yi) * (xa - xi);
}

int main(){
    cin>>N;
    rep(i,N){
        cin>>x[i]>>y[i]>>d[i];
        x[i] *= 2;
        y[i] *= 2;
    }
    search(true);
    search(false);
    ll ans = 1e+18;
    for(ll ti : t) {
        if(ti < (1e+9) - 5) {
            chmin(ans, solve(ti));
        }
    }
    /*ll tim = 0;
    rep(i,2000) if(chmin(ans, solve(i))) tim = i;*/
    cout<<fixed<<setprecision(10)<<((long double)ans) / 4.0<<endl;
    //cout<<tim<<endl;
}

Measured memory_bytes: 1920
import math

N=int(input())
sqN=int(math.sqrt(N))+1

def f(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x

dp=[0 for n in range(N)]
for x in range(1,sqN):
    for y in range(x,sqN):
        for z in range(y,sqN):
            tmp=f(x,y,z)
            c=len(set([x,y,z]))
            if tmp<=N:
                if c==1:
                    dp[tmp-1]+=1
                elif c==2:
                    dp[tmp-1]+=3
                else:
                    dp[tmp-1]+=6
            else:
                break
for n in range(len(dp)):
    print(dp[n])

Measured memory_bytes: 9140
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;

int l,r;

int main(){
	scanf("%d%d",&l,&r);
	if(l<=0&&0<=r) return puts("Zero"),0;
	printf("%s\n",(qmin(-1,r)-qmin(l,0)+1)&1?"Negative":"Positive");
	return 0;
}


Measured memory_bytes: 384
s = [list(map(int,input().split())) for i in range(3)]
t = []
for i in range(3):
    t.append([s[i][0]-s[i][1],s[i][0]-s[i][2]])
if t[0] == t[1] and t[0] == t[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

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

        boolean[] isPrime = makePrimes(100000);
        boolean[] isLike2017 = new boolean[100001];
        for (int i = 0; i <= 100000; i++) {
            isLike2017[i] = isPrime[i] && isPrime[(i + 1) / 2];
        }

        int[] sum = new int[100002];
        sum[0] = 0;
        for (int i = 0; i <= 100000; i++) {
            sum[i + 1] = sum[i];
            if (isLike2017[i]) {
                sum[i + 1]++;
            }
        }

        for (int i = 0; i < n; i++) {
            int l = in.nextInt();
            int r = in.nextInt();
            System.out.println(sum[r + 1] - sum[l]);
        }
    }

    private static boolean[] makePrimes(int n) {
        boolean[] isPrime = new boolean[n + 1];
        Arrays.fill(isPrime, false);
        for (int i = 0; i < n; i++) {
            isPrime[i] = true;
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for (int i = 2; i <= n; i++) {
            for (int j = i * 2; j <= n; j += i) {
                isPrime[j] = false;
            }
        }

        return isPrime;
    }
}


Measured memory_bytes: 63976
def main():
    n = int(input())
    s = input()
    r,g,b = 0,0,0
    for i in s:
        if i == 'R': r += 1
        elif i == 'G': g += 1
        elif i == 'B': b += 1
    ans = r*g*b
    for j in range(n):
        for i in range(j):
            k = j+(j-i)
            if k < n:
                if s[i] == s[j] or s[i] == s[k] or s[k] == s[j]:
                    continue
                ans -= 1
    print(ans)
if __name__ == "__main__":
    main()

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n,a,b;
    cin>>n>>a>>b;
    int mx = min(a,b);
    int mn = max(a+b-n,0);

    cout<<mx<<" "<<mn<<endl;
    
    return 0;
}


Measured memory_bytes: 3536
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	int N, C[501], S[501], F[501], x[501];

	cin >> N;
	REP(i, N - 1) {
		cin >> C[i + 1] >> S[i + 1] >> F[i + 1];
	}

	FOR(i, 1, N + 1) {
		int t = 0;
		if (i == N) {
			x[i] = 0;
		}
		else {
			FOR(j, i, N) {
				if (t <= S[j]) {
					t = S[j] + C[j];
				}
				else {
					t = ((t - S[j] + F[j] - 1) / F[j])*F[j] + S[j] + C[j];
				}
			}
		}
		x[i] = t;
	}

	REP(i, N) {
		cout << x[i + 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

char str[400009];
int cnt[30];

int main()
{
    scanf("%s",str);
    int len = strlen(str);
    for(int i=0; i<len; i++) ++cnt[(int)(str[i] - 'a')];
    long long ans = 0LL;
    for(int i=0; i<26; i++) ans += (long long)cnt[i] * (long long)(cnt[i] + 1) / 2LL;
    printf("%lld\n", (long long)len * (long long)(len + 1) / 2LL - ans + 1LL);
    return 0;
}


Measured memory_bytes: 384
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

ll n , x ;

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

	cin >> n >> x ;

	cout << 3 * (n - __gcd(n , x)) << '\n' ;
}


Measured memory_bytes: 256
S=input()
N=len(S)
a=[0]*(N+1)
for i in range(N):
  if S[i] == "<":
    a[i+1] = a[i]+1
for i in range(N-1,-1,-1):
  if S[i] == ">":
    a[i] = max(a[i+1]+1, a[i])
print(sum(a))

Measured memory_bytes: 23336
def main():
	from scipy.sparse.csgraph import floyd_warshall
	import numpy as np
	n, m, l, *L = map(int, open(0).read().split())
	abc = L[:3 * m];
	st = L[3 * m + 1:]
	r = [[float("inf")] * n for _ in range(n)]
	for a, b, c in zip(*[iter(abc)] * 3):
		if c <= l: r[a - 1][b - 1] = c
	fw = floyd_warshall(r, 0)
	ans = floyd_warshall(np.where(fw <= l, 1, fw), 0) - 1
	for s, t in zip(*[iter(st)] * 2):
		x = ans[s - 1, t - 1]
		if x == float("inf"):
			print(-1)
		else:
			print(int(x))


if __name__ == "__main__":
	main()

Measured memory_bytes: 40760
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    char a;
    cin >> a;
    if (isupper(a)) {
        cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 1010;
const int MAXD = 128;

int dp[MAXD][MAXN];

int t, n, d;

int main() {
    GI(t);

    while (t--) {
        GI(n); GI(d); n--;

        int res = 0;

        while (n--) {
            res += 127;
            d ^= 127;
        }

        printf("%d\n", res + d);
    }
    
    return 0;
}


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

vector<int> v[100001]={};
vector<int> vs(100001,-1);

void bfs(){
  int s = 1;
  vs[s]=0;
  queue<int> q;
  q.push(s);
  while(!q.empty()){
    int t = q.front();
    q.pop();
    int num = (int)v[t].size();
    for(int i=0; i<num; i++){
      if(vs[v[t][i]]==-1){
        q.push(v[t][i]);
        vs[v[t][i]]=t;
      }
    }
  }
  return;
}

int main(){
  int N, M;
  cin >> N >> M;
  for(int i=0; i<M; i++){
    int A, B;
    cin >> A >> B;
    v[A].push_back(B);
    v[B].push_back(A);
  }
  bfs();
  for(int i=2; i<=N; i++){
    if(vs[i]==-1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(int i=2; i<=N; i++){
    cout << vs[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 10328
#!usr/bin/env python3

import sys


class Die:
    def __init__(self, pips):
        self.pips = pips

    def move_die(self, direction):
        if direction == 'N':
            tmp = self.pips[0]
            self.pips[0] = self.pips[1]
            self.pips[1] = self.pips[5]
            self.pips[5] = self.pips[4]
            self.pips[4] = tmp
            del tmp
        elif direction == 'S':
            tmp = self.pips[0]
            self.pips[0] = self.pips[4]
            self.pips[4] = self.pips[5]
            self.pips[5] = self.pips[1]
            self.pips[1] = tmp
            del tmp
        elif direction == 'E':
            tmp = self.pips[0]
            self.pips[0] = self.pips[3]
            self.pips[3] = self.pips[5]
            self.pips[5] = self.pips[2]
            self.pips[2] = tmp
            del tmp
        elif direction == 'W':
            tmp = self.pips[0]
            self.pips[0] = self.pips[2]
            self.pips[2] = self.pips[5]
            self.pips[5] = self.pips[3]
            self.pips[3] = tmp
            del tmp

    def spin_die_clockwise(self):
        tmp = self.pips[1]
        self.pips[1] = self.pips[2]
        self.pips[2] = self.pips[4]
        self.pips[4] = self.pips[3]
        self.pips[3] = tmp
        del tmp


def init_die():
    pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]
    die = Die(pips)

    return die


def roll_die(die):
    directions = list(sys.stdin.readline().strip('\n'))

    for direction in directions:
        die.move_die(direction)

    return die


def question_rightside(die):
    q = int(sys.stdin.readline().strip('\n'))

    for question in range(q):
        q_pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]

        if q_pips[0] == die.pips[1]:
            die.move_die('N')
        elif q_pips[0] == die.pips[2]:
            die.move_die('W')
        elif q_pips[0] == die.pips[3]:
            die.move_die('E')
        elif q_pips[0] == die.pips[4]:
            die.move_die('S')
        elif q_pips[0] == die.pips[5]:
            die.move_die('N')
            die.move_die('N')

        while die.pips[1] != q_pips[1]:
            die.spin_die_clockwise()

        print(die.pips[2])


def main():
    die1 = init_die()
    die2 = init_die()

    if sorted(die1.pips) != sorted(die2.pips):
        print('No')
    else:
        for idx, pip in enumerate(die2.pips):
            for spin in range(4):
                if die1.pips == die2.pips:
                    print('Yes')
                    sys.exit(0)
                else:
                    die1.spin_die_clockwise()
            if idx in {0, 1, 2}:
                die1.move_die('N')
            if idx in {3}:
                die1.move_die('N')
                die1.move_die('E')
            if idx in {4}:
                die1.move_die('E')
                die1.move_die('E')

        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 7924
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int x, a;
    cin >> x >> a;
    if(x < a){
        cout << "0";
    }else{
        cout << "10";
    }
    return 0;
}

Measured memory_bytes: 3568
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {

    let l = read_t_in_line::<i32>();
    let (a, b, x) = (l[0], l[1], l[2]);
    if a <= x && x <= a + b {
        println!("YES");
    }
    else{
        println!("NO");
    }
    
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
const int maxn = 55;
string res;
bool vis[maxn][maxn][maxn][maxn];
int failure[maxn], link[maxn][3], final_ok[maxn];
void push(){
    memset(failure, 0, sizeof(failure));
    for(int s = 2; s <= res.size(); s++){
        failure[s] = failure[s-1];
        while(failure[s] > 0 && res[failure[s]] != res[s-1])
            failure[s] = failure[failure[s]];
        if(res[failure[s]] == res[s-1]) ++failure[s];
    }
    for(int s = 0; s < res.size(); s++){
        for(int e = 0; e < 3; e++){
            int pos = s;
            if(res[s] > 'a' + e) link[s][e] = -1;
            else{
                while(pos > 0 && res[pos] != 'a' + e) pos = failure[pos];
                if(res[pos] == 'a' + e) pos++;
                link[s][e] = pos;
            }
        }
    }
    for(int s = 0; s < res.size(); s++){
        int pos = s;
        final_ok[pos] = 1;
        for(int e = 0; e < res.size(); e++){
            pos = link[pos][res[e] - 'a'];
            if(pos == -1){
                final_ok[s] = 0;
                break;
            }
        }
    }
}
bool solve(int x, int y, int z, int px){
    if(px == res.size()) px = failure[px];
    if(x + y + z == 0) return final_ok[px];
    if(vis[x][y][z][px]) return false;
    vis[x][y][z][px] = true;
    if(link[px][0] != -1 && x && solve(x - 1, y, z, link[px][0])) return true;
    if(link[px][1] != -1 && y && solve(x, y - 1, z, link[px][1])) return true;
    if(link[px][2] != -1 && z && solve(x, y, z - 1, link[px][2])) return true;
    return false;
}
int M(){
    int x, y, z;
    if(!(cin >> x >> y >> z)) return 0;
    int len = x + y + z;
    res.clear();
    for(int e = 0; e < len; e++){
        res.push_back('c');
        push();
        memset(vis, 0, sizeof(vis));
        if(solve(x, y, z, 0)) continue;
        res.back() = 'b';
        push();
        memset(vis, 0, sizeof(vis));
        if(solve(x, y, z, 0)) continue;
        res.back() = 'a';
    }
    cout << res << endl;
    return 1;
}
int main(){
    while(M());
    return 0;
}


Measured memory_bytes: 9344
#include "bits/stdc++.h"
using namespace std;
int main(){
	typedef long long ll;

  ll dp[10][1001];
  memset(dp,0,sizeof(dp));
  dp[0][0] = 1;
  for(int num=0;num<=100;num++){
    for(int i=9;i>0;i--){
      for(int to=1000;to-num>=0;to--){
    dp[i][to] += dp[i-1][to-num];
      }
    }
  }

  int n,s;
  while(~scanf("%d %d",&n,&s)){
    if(n==0 && s==0) break;
    printf("%lld\n",dp[n][s]);
  }
}

Measured memory_bytes: 3272
N,x = map(int,input().split())
a = list(map(int,input().split()))
count = 0
#昇順に並べ替える
# sort_a = sorted(a)
a.sort(reverse=False)
for i in range(N):
    if x >= a[i]:
        count += 1
        x -= a[i]
    else:
        break

if (x!=0)and(count == N):
    count -= 1
print(count)


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

using ll = long long;
static const ll MOD = 998244353;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  vector<vector<int>> x(k, vector<int>(2));
  for (int i = 0; i < k; i++) cin >> x.at(i).at(0) >> x.at(i).at(1);
  
  vector<ll> dp(n + 1, 0), acc(n + 1, 0);
  dp[1] = 1;
  acc[1] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < k; j++) {
      if (i - x[j][0] <= 0) continue;
      int left = max(0, i - x[j][1] - 1);
      dp[i] += acc[i - x[j][0]] - acc[left];
      dp[i] = (dp[i] + MOD) % MOD;
    }
    acc[i] = dp[i] + acc[i - 1];
    acc[i] %= MOD;
    //cout << dp[i] << endl;
  }
  
  cout << dp[n] << '\n';
}

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

using namespace std;

int main() {
  int h, w;
  int a, b;

  cin >> h >> w;
  cin >> a >> b;

  // 覆う面積
  int s1, s2;
  // そのままの向きで並べる場合
  s1 = (w/b)*(h/a)*a*b;
  // 90度回転させてから並べる場合
  // s2 = (w/a)*(h/b)*a*b;

  // cout << h*w-(max(s1, s2)) << endl;
  cout << h*w-s1 << endl;

  return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	string s, t = "2019/04/30";
	cin >> s;
	if (s > t) {
		cout << "TBD" << endl;
	}
	else {
		cout << "Heisei" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
while True:
  n,x = map(int, input().split())
  a = 0
  if n == x == 0:
    break
  else:
    for i in range(1, n-1):
      for j in range(i+1, n):
        for k in range(j+1,n+1):
          if i+j+k == x:
            a += 1
  print(a)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n, m;

	cin >> n >> m;

	string a[n];
	string b[m];
	bool found;

	int i, j, len = n - m + 1;
	int k, l;

	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];

	rep(i, len) {
		rep(j, len) {
			found = true;

			rep(k, m) {
				rep(l, m) {
					if (a[i + k][j + l] != b[k][l]) {
						found = false;

						break;
					}
				}

				if (!found) break;
			}

			if (found) {
				Out("Yes");

				return 0;
			}
		}
	}

	Out("No");
	
	return 0;
}


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

using namespace std;
using namespace std::chrono;

#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

const ll big = 1000000007ll;
const ll big2 = 1000000009ll;
ll n,m,k,q,w,h;

ll gcd(ll i, ll j){
    if(j == 0)return i;
    return gcd(j,i%j);
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d;

    cin >> n >> m >> k;

    bool yes = 0;

    for(ll c1 = 0; c1 <= n; c1++){
        for(ll c2 = 0; c2 <= m; c2++){
            if(c1*m + c2*n - 2*c1*c2 == k)yes = 1;
            //cout << c1*m + c2*n - 2*c1*c2 << "\n";
        }
    }

    if(yes){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  if(S[6]=='3'||S[6]=='4')
  {
    cout << "Heisei" << endl;
  }
  else if(S[5]=='0'&&S[6]=='1')
  {
    cout << "Heisei" << endl;
  }
  else if(S[5]=='0'&&S[6]=='2')
  {
    cout << "Heisei" << endl;
  }
  else
  {
    cout << "TBD" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

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

using namespace std;

void solution()
{
    int n,k;
    cin >> n >> k;

    double p = 0;

    for(int a = 1; a <= n; ++a){
        int t = a;
        int x = 0;
        while(t < k){
            x += 1;
            t *= 2;
        }
        p += 1/(pow(2, x)*n);
    }
    cout << p << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


Measured memory_bytes: 256